QOJ.ac

QOJ

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

#16115. 합 게임

统计

Ana와 Bob은 다음 게임을 합니다.

먼저, Bob이 $n$개의 양의 정수로 이루어진 수열 $a_1, a_2, \dots, a_n$을 선택합니다. 그런 다음 Ana는 다음 연산을 수행할 수 있습니다.

  • 수열에서 원하는 수들을 지울 수 있지만, 모든 수를 지울 수는 없습니다(적어도 하나의 수는 남아 있어야 합니다).
  • 남아 있는 각 수의 앞에 + 또는 - 부호 중 하나를 붙일 수 있습니다.

그 후, Ana는 남아 있는 수들의 합을 계산합니다. 만약 $m$으로 나누어떨어지는 합을 얻을 수 있다면 Ana가 게임에서 이깁니다. 그렇지 않으면 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.