Gym - 100952G (博弈)

Statements

Alice and Bob play the following game. They choose a number N to play with. The rules are as follows:

- They write each number from 1 to N on a paper and put all these papers in a jar.

- Alice plays first, and the two players alternate.

- In his/her turn, a player can select any available number M and remove its divisors including M.

- The person who cannot make a move in his/her turn wins the game.

Assuming both players play optimally, you are asked the following question: who wins the game?

Input

The first line contains the number of test cases T (1 ?≤? T ?≤? 20). Each of the next T lines contains an integer (1 ?≤? N ?≤? 1,000,000,000).

Output

Output T lines, one for each test case, containing Alice if Alice wins the game, or Bob otherwise.

Example

Input

251

Output

AliceBob
 1 #include <iostream>
 2 #include <stdio.h>
 3 using namespace std;
 4
 5 int main(){
 6     int T; scanf("%d", &T);
 7     while(T--){
 8         int n;
 9         scanf("%d", &n);
10         if(n>1) printf("Alice\n");
11         else printf("Bob\n");
12     }
13     return 0;
14 }
15 /*
16 题意:有一个容器里装着 n个数,
17 A和B每次任意说一个数m,
18 那么他要拿走容器里m的所有因子,
19 如果谁拿空了容器,那么他输了,
20 求先手赢还是后手赢
21
22 思路:只有1是后手赢,
23 因为1只能拿一次,
24 大于1的情况,
25 假设a和b都不是聪明的,
26 假设先手出x,后手出y
27 结果是后手赢,
28 那么现在a和b都是聪明的,
29 先手可以直接出x*y(
30 即先手可以复制后手的操作,
31 先手的操作可以包括后手的操作),
32 则可以赢后手,
33 所以大于1的情况一定是先手赢
34 */
时间: 2024-12-28 21:31:44

Gym - 100952G (博弈)的相关文章

Gym - 101246D 博弈

题意:一个无向有环的图,从 1 号结点起火,开始蔓延,两个绝顶聪明的人轮流走,谁不能走谁输,输出输的人: 分析: 当时知道是博弈,但是想当然的以为 1 号结点有一个奇数层,就必胜:其实不是这样的,当一个人往奇数层走的时候,来到分叉点,另一个会找一个偶数走. 于是,还是得用SG博弈, 1.将图转换为一个有向无环图: 2.SG函数,下一个状态是子节点: #include <bits/stdc++.h> using namespace std; int n,m; const int maxn = 1

Gym - 100952G

G. The jar of divisors Alice and Bob play the following game. They choose a number N to play with. The rules are as follows: - They write each number from 1 to N on a paper and put all these papers in a jar. - Alice plays first, and the two players a

Gym 100827G Number Game (博弈)

Number Game Alice and Bob are playing a game on a line of N squares. The line is initially populated with one of each of the numbers from 1 to N. Alice and Bob take turns removing a single number from the line, subject to the restriction that a numbe

Gym - 100548H The Problem to Make You Happy 2014-2015 ACM-ICPC, Asia Xian Regional Contest (BFS+博弈)

题意:Bob和Alice在一张有向无环图上移动,给定二者的起点,Bob先手.Bob的失败条件是不能移动或者与Alice相遇.两个人都采取最优策略,求Bob是否会赢 分析:银牌题.先确定所有的失败状态,然后根据这些反向状态BFS. 用\(dp[i][j][0or1]\)表示bob在i点,Alice在j点,当前移动的人是bob还是Alice的情况, bob是否必败. 首先能确定的是 \(dp[i][j][0] = dp[i][j][1] = 0\), 对于出度为0的点\(i\),\(dp[i][j]

gym/102059/problem/I. Game on Plane SG函数做博弈

传送门: 题意: 给定一个正n边形的点.双方轮流连点成线,要求所画的线不能与之前的线相交.当某个人连成一个回路,这个人就输了.问先手必胜还是后手必胜. 思路: SG函数,因为一条线相当于把图劈成了两半,所以每次用异或运算推过来. /* * @Author: chenkexing * @Date: 2019-01-13 16:17:46 * @Last Modified by: chenkexing * @Last Modified time: 2019-01-15 18:33:24 */ #in

Gym 101246D Fire in the Country(dfs求SG函数)

http://codeforces.com/gym/101246/problem/D 题意: 给定一个无向有环图,大火从1点开始,每个时间点与它相邻的点也将会着火,现在有两个人轮流操作机器人,机器人从1点出发,每个人每次选择一个点走,谁最后被火烧了谁就输了. 思路: 博弈题. 我们先预处理求出每个点着火的时间点,然后根据时间点重建新图,也就是重新建一个有向无环图,原来图中相连的并且时间点相差1的相连,由时间低的连向时间高的. 接下来我们在新图上求每个点的SG值,SG值为0的点就是叶子结点,这样父

Codeforces Gym 100496J(模拟乱搞,线段相交)

题意:给一个M*N的矩形区域,有M*N个方格,有些方格为空(可到达),有些非空(不可达).现A和B在博弈,他们任选两个不同的空格,站在各自的格子中央,A可以移动,但只能进行一次行方向或列向方移动,移动后仍然在格子中央.A如果移动到一个位置使得B看不见他,则A获胜.B看不见A的条件是存在一个非空格子与B到A的线段相切或相交.问,对于每个空格子,A站在上面,是否无论B在哪里,他都可以移动到一个安全位置. A可以选择不移动,题目保证至少有两个空格子,每次移动只能进行横向或竖向移动,不能都进行.空格子内

Marbles(博弈SG函数)

Marbles Gym - 101908B Using marbles as a currency didn't go so well in Cubic?nia. In an attempt to make it up to his friends after stealing their marbles, the Emperor decided to invite them to a game night in his palace. Of course, the game uses marb

苹果不再“雁过拔毛”的背后:利益博弈下谁是赢家?

自从库克成为苹果大当家后,苹果似乎就一直奔着利润一股脑地扎进去了.iPhone万年不变样,就连有所改变的iPhone X在售价上也是"穷凶极恶",吃相极其难看.而在今年4月份腾讯微信官方发布通告,更是将苹果推上风口浪尖.微信官方表示,由于受苹果公司新规定影响,iOS 平台的微信客户端关闭公众号打赏功能. 至于微博问答.知乎问答.今日头条及众多直播平台等在内,都逃不过苹果的"雁过拔毛"--苹果认为应用上的打赏属于"内购"行为,去抽取30%的分成.但