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 は以下の操作を行うことができます。

  • 列から任意の数を消去してよいが、すべてを消去することはできない(少なくとも1つの数は残さなければならない)。
  • 残ったそれぞれの数の前に、+ または - の符号のいずれかを付けることができる。

その後、Ana は残った数の総和を計算します。$m$ で割り切れる総和を得ることができれば Ana の勝ちです。そうでなければ Bob の勝ちです。

$n$ と $m$ が与えられるので、どちらのプレイヤーに必勝戦略があるかを判定してください。

入力

最初の行には、テストケースの個数を表す単一の整数 $t$ が含まれます。 続く $t$ 行のそれぞれには、2つの整数 $n$ と $m$ が含まれます。

出力

各テストケースについて、1行出力してください。

  • 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

注記

1番目のテストケースでは、Bob は $a_1 = 3$ を選ぶことができます。 2番目のテストケースでは、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.