QOJ.ac

QOJ

시간 제한: 2.0 s 메모리 제한: 1024 MB 총점: 100 해킹 가능 ✓

#15032. Chiffer

통계

Alice har konstruerat ett chiffersystem: det kodar klartexten som ett 64-bitars teckenlöst heltal $x$, väljer slumpmässigt ett 64-bitars teckenlöst heltal $a$ som publik nyckel och krypterar klartexten för att få chiffertexten $b = a^x \bmod 2^{64}$. Speciellt definieras $0^0 = 1$.

Nu har Bob snappat upp $n$ uppsättningar krypterad information $(a_i, b_i)$ ($i = 1, 2, \dots, n$). För att dekryptera all information behöver Bob för varje uppsättning krypterad information hitta det minsta heltalet $x_i$ ($0 \le x_i < 2^{64}$) sådant att $a_i^{x_i} \equiv b_i \pmod{2^{64}}$, eller avgöra att informationen har skadats (d.v.s. att det inte finns något $x_i$ som uppfyller villkoret). Skriv ett program som hjälper Bob att utföra denna uppgift.

Indata

Den första raden i indatan innehåller ett heltal $n$ ($1 \le n \le 10^5$), som representerar antalet meddelanden.

På de följande $n$ raderna innehåller den $i$:te raden två heltal $a_i$ och $b_i$ ($0 \le a_i, b_i < 2^{64}$), som representerar den publika nyckeln respektive chiffertexten för den $i$:te informationsuppsättningen.

Utdata

Skriv ut $n$ rader, där den $i$:te raden ska innehålla:

  • Om det finns minst ett $x_i$ som uppfyller villkoren i problemet, skriv ut det minsta av dem;
  • Annars, skriv ut en rad med broken message.

Exempel

Indata

5
2 4
3 27
1000000007 998244353
4 2
1000000007 1000000009

Utdata

2
3
994996658310742016
broken message
broken message

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
#3008EditorialOpen题解KobicGendView
#904EditorialOpenNew Editorial for Problem #15032KiharaToumaView

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.