A16029 | Game with Board
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Alice and Bob play a game. They have a blackboard; initially, there are $n$ integers written on it, and each integer is equal to $1$ .
Alice and Bob take turns; Alice goes first. On their turn, the player has to choose several (at least two) equal integers on the board, wipe them and write a new integer which is equal to their sum.
For example, if the board currently contains integers $\{1, 1, 2, 2, 2, 3\}$ , then the following moves are possible:
- choose two integers equal to $1$ , wipe them and write an integer $2$ , then the board becomes $\{2, 2, 2, 2, 3\}$ ;
- choose two integers equal to $2$ , wipe them and write an integer $4$ , then the board becomes $\{1, 1, 2, 3, 4\}$ ;
- choose three integers equal to $2$ , wipe them and write an integer $6$ , then the board becomes $\{1, 1, 3, 6\}$ .
If a player cannot make a move (all integers on the board are different), that player wins the game.
Determine who wins if both players play optimally.
Alice and Bob take turns; Alice goes first. On their turn, the player has to choose several (at least two) equal integers on the board, wipe them and write a new integer which is equal to their sum.
For example, if the board currently contains integers $\{1, 1, 2, 2, 2, 3\}$ , then the following moves are possible:
- choose two integers equal to $1$ , wipe them and write an integer $2$ , then the board becomes $\{2, 2, 2, 2, 3\}$ ;
- choose two integers equal to $2$ , wipe them and write an integer $4$ , then the board becomes $\{1, 1, 2, 3, 4\}$ ;
- choose three integers equal to $2$ , wipe them and write an integer $6$ , then the board becomes $\{1, 1, 3, 6\}$ .
If a player cannot make a move (all integers on the board are different), that player wins the game.
Determine who wins if both players play optimally.
输入格式
The first line contains one integer $t$ ( $1 \le t \le 99$ ) — the number of test cases.
Each test case consists of one line containing one integer $n$ ( $2 \le n \le 100$ ) — the number of integers equal to $1$ on the board.
Each test case consists of one line containing one integer $n$ ( $2 \le n \le 100$ ) — the number of integers equal to $1$ on the board.
输出格式
For each test case, print Alice if Alice wins when both players play optimally. Otherwise, print Bob.
输入输出样例
输入 #1
2 3 6
输出 #1
Bob Alice
In the first test case, $n = 3$ , so the board initially contains integers $\{1, 1, 1\}$ . We can show that Bob can always win as follows: there are two possible first moves for Alice.
- if Alice chooses two integers equal to $1$ , wipes them and writes $2$ , the board becomes $\{1, 2\}$ . Bob cannot make a move, so he wins;
- if Alice chooses three integers equal to $1$ , wipes them and writes $3$ , the board becomes $\{3\}$ . Bob cannot make a move, so he wins.
In the second test case, $n = 6$ , so the board initially contains integers $\{1, 1, 1, 1, 1, 1\}$ . Alice can win by, for example, choosing two integers equal to $1$ , wiping them and writing $2$ on the first turn. Then the board becomes $\{1, 1, 1, 1, 2\}$ , and there are three possible responses for Bob:
- if Bob chooses four integers equal to $1$ , wipes them and writes $4$ , the board becomes $\{2,4\}$ . Alice cannot make a move, so she wins;
- if Bob chooses three integers equal to $1$ , wipes them and writes $3$ , the board becomes $\{1,2,3\}$ . Alice cannot make a move, so she wins;
- if Bob chooses two integers equal to $1$ , wipes them and writes $2$ , the board becomes $\{1, 1, 2, 2\}$ . Alice can continue by, for example, choosing two integers equal to $2$ , wiping them and writing $4$ . Then the board becomes $\{1,1,4\}$ . The only possible response for Bob is to choose two integers equal to $1$ and write $2$ instead of them; then the board becomes $\{2,4\}$ , Alice cannot make a move, so she wins.
- if Alice chooses two integers equal to $1$ , wipes them and writes $2$ , the board becomes $\{1, 2\}$ . Bob cannot make a move, so he wins;
- if Alice chooses three integers equal to $1$ , wipes them and writes $3$ , the board becomes $\{3\}$ . Bob cannot make a move, so he wins.
In the second test case, $n = 6$ , so the board initially contains integers $\{1, 1, 1, 1, 1, 1\}$ . Alice can win by, for example, choosing two integers equal to $1$ , wiping them and writing $2$ on the first turn. Then the board becomes $\{1, 1, 1, 1, 2\}$ , and there are three possible responses for Bob:
- if Bob chooses four integers equal to $1$ , wipes them and writes $4$ , the board becomes $\{2,4\}$ . Alice cannot make a move, so she wins;
- if Bob chooses three integers equal to $1$ , wipes them and writes $3$ , the board becomes $\{1,2,3\}$ . Alice cannot make a move, so she wins;
- if Bob chooses two integers equal to $1$ , wipes them and writes $2$ , the board becomes $\{1, 1, 2, 2\}$ . Alice can continue by, for example, choosing two integers equal to $2$ , wiping them and writing $4$ . Then the board becomes $\{1,1,4\}$ . The only possible response for Bob is to choose two integers equal to $1$ and write $2$ instead of them; then the board becomes $\{2,4\}$ , Alice cannot make a move, so she wins.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted