Codeforces Round 1079 (Div. 2)
C
Game with a Fraction
Codeforces
未评级
原题
← BD →
翻译中…

Alice and Bob have two integers $p$ and $q$, and they are playing a game with these numbers. The players take turns, with Alice going first. On their turn, a player can do one of two actions:

翻译中…
  • decrease $p$ by one (this action is possible if $p \gt 0$);
  • decrease $q$ by one (this action is possible if $q \gt 1$).
翻译中…

The game ends when $p = 0$ and $q = 1$.

翻译中…

Bob wins if at any point during the game the fraction $\frac{p}{q}$ is equal to in value the fraction $\frac{2}{3}$. Otherwise, Alice wins.

翻译中…

Given the initial values of $p$ and $q$, determine the winner of the game if both players play optimally.

翻译中…

Input

翻译中…

Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 10^4$). The description of the test cases follows.

翻译中…

Each input case consists of a single line containing two integers $p$ and $q$ ($1 \le p, q \le 10^{18}$).

翻译中…

Output

翻译中…

For each input case, output:

翻译中…
  • "Alice" if Alice wins;
  • "Bob" if Bob wins.
翻译中…

Note

翻译中…

In the first input case, the fraction is already equal to $\frac{2}{3}$ by value, so Bob wins.

翻译中…

In the second input case, one possible sequence of the game is as follows:

翻译中…
  • initially $p = 10, q = 14$;
  • after Alice's turn $p = 9, q = 14$;
  • after Bob's turn $p = 9, q = 13$;
  • after Alice's turn $p = 9, q = 12$;
  • after Bob's turn $p = 8, q = 12$.
翻译中…

Bob wins, as $\frac{8}{12}$ is equal to $\frac{2}{3}$. It can be shown that in this example, with optimal play from both players, Bob always wins.

翻译中…

For the third input case, Alice's optimal strategy will be to decrease $q$ as long as possible. In this case, the game will end in favor of Alice regardless of Bob's actions.

翻译中…

样例

Input #1
6
4 6
10 14
15 15
7 12
7000000000000000 10487275715782582
1000000000000000000 1000000000000000000
Output #1
Bob
Bob
Alice
Alice
Bob
Alice
InputCopy OutputCopy
题目信息
题号
2197C
时间限制
2 s
内存限制
256 MB

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。