QOJ.ac

QOJ

Süre Sınırı: 2.0 s Bellek Sınırı: 1024 MB Toplam puan: 100 Hack'lenebilir ✓

#15032. צופן

İstatistikler

Alice תכננה מערכת הצפנה: היא מקודדת את הטקסט הגלוי כמספר שלם ללא סימן באורך 64 סיביות $x$, בוחרת באקראי מספר שלם ללא סימן באורך 64 סיביות $a$ כמפתח ציבורי, ומצפינה את הטקסט הגלוי לקבלת הטקסט המוצפן $b = a^x \bmod 2^{64}$. בפרט, מוגדר כי $0^0 = 1$.

כעת, Bob יירט $n$ קבוצות של מידע מוצפן $(a_i, b_i)$ ($i = 1, 2, \dots, n$). כדי לפענח את כל המידע, Bob צריך למצוא עבור כל קבוצת מידע מוצפן את המספר השלם הקטן ביותר $x_i$ ($0 \le x_i < 2^{64}$) המקיים $a_i^{x_i} \equiv b_i \pmod{2^{64}}$, או לקבוע שהמידע נפגם (כלומר, לא קיים $x_i$ המקיים את התנאי). אנא כתבו תוכנית שתעזור ל-Bob להשלים משימה זו.

קלט

השורה הראשונה של הקלט מכילה מספר שלם $n$ ($1 \le n \le 10^5$), המייצג את מספר ההודעות.

ב-$n$ השורות הבאות, השורה ה-$i$ מכילה שני מספרים שלמים $a_i$ ו-$b_i$ ($0 \le a_i, b_i < 2^{64}$), המייצגים את המפתח הציבורי ואת הטקסט המוצפן של קבוצת המידע ה-$i$, בהתאמה.

פלט

הדפיסו $n$ שורות, עבור השורה ה-$i$:

  • אם קיים לפחות $x_i$ אחד המקיים את התנאים המתוארים בבעיה, הדפיסו את הקטן ביותר מביניהם;
  • אחרת, הדפיסו שורה המכילה broken message.

דוגמה

קלט

5
2 4
3 27
1000000007 998244353
4 2
1000000007 1000000009

פלט

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.