QOJ.ac

QOJ

时间限制: 1.0 s 内存限制: 512 MB 总分: 100

#16115. Trò chơi tính tổng

统计

Ana và Bob chơi trò chơi sau đây.

Đầu tiên, Bob chọn một dãy gồm $n$ số nguyên dương $a_1, a_2, \dots, a_n$. Sau đó Ana được phép thực hiện các thao tác sau.

  • Cô ấy có thể xóa bất kỳ số nào khỏi dãy, nhưng không được phép xóa tất cả chúng (ít nhất một số phải còn lại).
  • Đối với mỗi số còn lại, cô ấy có thể đặt dấu + hoặc dấu - ở phía trước nó.

Sau đó, Ana tính tổng của các số còn lại. Cô ấy thắng trò chơi nếu có thể thu được một tổng chia hết cho $m$. Ngược lại, Bob thắng.

Cho $n$ và $m$, hãy xác định xem người chơi nào có chiến lược thắng.

Dữ liệu vào

Dòng đầu tiên chứa một số nguyên $t$ — số lượng bộ dữ liệu. Mỗi dòng trong $t$ dòng tiếp theo chứa hai số nguyên $n$ và $m$.

Dữ liệu ra

Đối với mỗi bộ dữ liệu, in ra một dòng duy nhất.

  • Ana — nếu Ana có chiến lược thắng,
  • Bob — nếu Bob có chiến lược thắng.

Giới hạn

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

Ví dụ

Dữ liệu vào 1

3
1 2
2 3
3 8

Dữ liệu ra 1

Bob
Ana
Bob

Ghi chú

Ở bộ dữ liệu thứ nhất, Bob có thể chọn $a_1 = 3$. Ở bộ dữ liệu thứ hai, bất kể Bob chọn $a_1, a_2$ như thế nào, Ana đều có chiến lược thắng.

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.