A16392 | Wallet Exchange
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Alice and Bob are bored, so they decide to play a game with their wallets. Alice has $a$ coins in her wallet, while Bob has $b$ coins in his wallet.
Both players take turns playing, with Alice making the first move. In each turn, the player will perform the following steps in order:
1. Choose to exchange wallets with their opponent, or to keep their current wallets.
2. Remove $1$ coin from the player's current wallet. The current wallet cannot have $0$ coins before performing this step.
The player who cannot make a valid move on their turn loses. If both Alice and Bob play optimally, determine who will win the game.
Both players take turns playing, with Alice making the first move. In each turn, the player will perform the following steps in order:
1. Choose to exchange wallets with their opponent, or to keep their current wallets.
2. Remove $1$ coin from the player's current wallet. The current wallet cannot have $0$ coins before performing this step.
The player who cannot make a valid move on their turn loses. If both Alice and Bob play optimally, determine who will win the game.
输入格式
Each test contains multiple test cases. The first line contains a single integer $t$ ( $1 \leq t \leq 1000$ ) — the number of test cases. The description of the test cases follows.
The first and only line of each test case contains two integers $a$ and $b$ ( $1 \le a, b \le 10^9$ ) — the number of coins in Alice's and Bob's wallets, respectively.
The first and only line of each test case contains two integers $a$ and $b$ ( $1 \le a, b \le 10^9$ ) — the number of coins in Alice's and Bob's wallets, respectively.
输出格式
For each test case, output "Alice" if Alice will win the game, and "Bob" if Bob will win the game.
输入输出样例
输入 #1
10 1 1 1 4 5 3 4 5 11 9 83 91 1032 9307 839204 7281 1000000000 1000000000 53110 2024
输出 #1
Bob Alice Bob Alice Bob Bob Alice Alice Bob Bob
In the first test case, an example of the game is shown below:
- Alice chooses to not swap wallets with Bob in step 1 of her move. Now, $a=0$ and $b=1$ .
- Since Alice's wallet is empty, Bob must choose to not swap their wallets in step 1 of his move. Now, $a=0$ and $b=0$ .
- Since both Alice's and Bob's wallets are empty, Alice is unable to make a move. Hence, Bob wins.
In the second test case, an example of the game is shown below:
- Alice chooses to swap wallets with Bob in step 1 of her move. Now, $a=3$ and $b=1$ .
- Bob chooses to swap wallets with Alice in step 1 of his move. Now, $a=1$ and $b=2$ .
- Alice chooses to not swap wallets with Bob in step 1 of her move. Now, $a=0$ and $b=2$ .
- Since Alice's wallet is empty, Bob can only choose to not swap wallets with Alice in step 1 of his move. Now, $a=0$ and $b=1$ .
- Since Alice's wallet is empty, Alice can only choose to swap wallets with Bob in step 1 of her move. Now, $a=0$ and $b=0$ .
- Since both Alice's wallet and Bob's wallet are empty, Bob is unable to make a move. Hence, Alice wins.
- Alice chooses to not swap wallets with Bob in step 1 of her move. Now, $a=0$ and $b=1$ .
- Since Alice's wallet is empty, Bob must choose to not swap their wallets in step 1 of his move. Now, $a=0$ and $b=0$ .
- Since both Alice's and Bob's wallets are empty, Alice is unable to make a move. Hence, Bob wins.
In the second test case, an example of the game is shown below:
- Alice chooses to swap wallets with Bob in step 1 of her move. Now, $a=3$ and $b=1$ .
- Bob chooses to swap wallets with Alice in step 1 of his move. Now, $a=1$ and $b=2$ .
- Alice chooses to not swap wallets with Bob in step 1 of her move. Now, $a=0$ and $b=2$ .
- Since Alice's wallet is empty, Bob can only choose to not swap wallets with Alice in step 1 of his move. Now, $a=0$ and $b=1$ .
- Since Alice's wallet is empty, Alice can only choose to swap wallets with Bob in step 1 of her move. Now, $a=0$ and $b=0$ .
- Since both Alice's wallet and Bob's wallet are empty, Bob is unable to make a move. Hence, Alice wins.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted