QOJ.ac

QOJ

حد الوقت: 1.0 s حد الذاكرة: 512 MB مجموع النقاط: 100

#16115. เกมผลรวม

الإحصائيات

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.