QOJ.ac

QOJ

Time Limit: 1.0 s Memory Limit: 512 MB Total points: 100

#16115. משחק הסכום

Statistics

Ana ו-Bob משחקים במשחק הבא.

תחילה, Bob בוחר סדרה של $n$ מספרים שלמים חיוביים $a_1, a_2, \dots, a_n$. לאחר מכן, Ana רשאית לבצע את הפעולות הבאות.

  • היא רשאית למחוק כל אחד מהמספרים מהסדרה, אך אסור לה למחוק את כולם (לפחות מספר אחד חייב להישאר).
  • עבור כל מספר שנותר, היא רשאית לשים סימן + או - לפניו.

לאחר מכן, Ana מחשבת את סכום המספרים שנותרו. היא מנצחת במשחק אם היא יכולה לקבל סכום המתחלק ב-$m$. אחרת, Bob מנצח.

בהינתן $n$ ו-$m$, קבעו לאיזה שחקן יש אסטרטגיית ניצחון.

קלט

השורה הראשונה מכילה מספר שלם יחיד $t$ — מספר מקרי הבדיקה. כל אחת מ-$t$ השורות הבאות מכילה שני מספרים שלמים $n$ ו-$m$.

פלט

עבור כל מקרה בדיקה, הדפיסו שורה אחת.

  • Ana — אם ל-Ana יש אסטרטגיית ניצחון,
  • Bob — אם ל-Bob יש אסטרטגיית ניצחון.

אילוצים

$1 \le t \le 10^5$, $1 \le n, m \le 10^{18}$.

דוגמאות

קלט 1

3
1 2
2 3
3 8

פלט 1

Bob
Ana
Bob

הערה

במקרה הבדיקה הראשון, Bob יכול לבחור $a_1 = 3$. במקרה הבדיקה השני, ללא קשר לאופן שבו Bob בוחר את $a_1, a_2$, ל-Ana יש אסטרטגיית ניצחון.

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.