CF1841A.Game with Board
入门
通过率:0%
时间限制:2.00s
内存限制:512MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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.
爱丽丝和鲍勃进行一场游戏。他们有一块黑板,初始时黑板上写有 n 个整数,每个整数均为 1。
爱丽丝和鲍勃轮流进行操作,爱丽丝先手。在每一轮中,当前玩家必须在黑板上选择若干(至少两个)相等的整数,将它们擦除,并写下一个等于这些整数之和的新整数。
例如,若黑板当前包含整数 1,1,2,2,2,3,则以下操作是可行的:
- 选择两个值为 1 的整数,擦除它们并写入整数 2,此时黑板变为 2,2,2,2,3;
- 选择两个值为 2 的整数,擦除它们并写入整数 4,此时黑板变为 1,1,2,3,4;
- 选择三个值为 2 的整数,擦除它们并写入整数 6,此时黑板变为 1,1,3,6。
若某位玩家无法进行操作(即黑板上所有整数互不相同),则该玩家获胜。
假设双方均以最优策略进行游戏,判断谁将获胜。
输入格式
The first line contains one integer t (1≤t≤99) — the number of test cases.
Each test case consists of one line containing one integer n (2≤n≤100) — the number of integers equal to 1 on the board.
第一行包含一个整数 t(1≤t≤99)—— 测试用例的数量。
每个测试用例由一行组成,该行包含一个整数 n(2≤n≤100)—— 黑板上等于 1 的整数的个数。
输出格式
For each test case, print Alice if Alice wins when both players play optimally. Otherwise, print Bob.
对于每个测试用例,如果双方都采取最优策略时 Alice 获胜,则输出 Alice;否则输出 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.
在第一个测试用例中,n=3,因此初始棋盘上包含整数 1,1,1。我们可以如下说明 Bob 总是获胜:Alice 有两种可能的首次操作。
- 若 Alice 选择两个值为 1 的整数,将其擦除并写入 2,则棋盘变为 1,2。Bob 无法进行任何操作,因此 Bob 获胜;
- 若 Alice 选择三个值为 1 的整数,将其擦除并写入 3,则棋盘变为 3。Bob 无法进行任何操作,因此 Bob 获胜。
在第二个测试用例中,n=6,因此初始棋盘上包含整数 1,1,1,1,1,1。Alice 可以通过如下方式获胜(例如):在第一回合选择两个值为 1 的整数,将其擦除并写入 2。此时棋盘变为 1,1,1,1,2,Bob 有三种可能的回应:
- 若 Bob 选择四个值为 1 的整数,将其擦除并写入 4,则棋盘变为 2,4。Alice 无法进行任何操作,因此 Alice 获胜;
- 若 Bob 选择三个值为 1 的整数,将其擦除并写入 3,则棋盘变为 1,2,3。Alice 无法进行任何操作,因此 Alice 获胜;
- 若 Bob 选择两个值为 1 的整数,将其擦除并写入 2,则棋盘变为 1,1,2,2。接着 Alice 可继续操作(例如):选择两个值为 2 的整数,将其擦除并写入 4,此时棋盘变为 1,1,4。Bob 唯一可能的操作是选择两个值为 1 的整数,并将其替换为 2;此时棋盘变为 2,4,Alice 无法进行任何操作,因此 Alice 获胜。
输入解题思路,AI测评打分。不知道怎么写?