G. The jar of divisors

time limit per test:2 seconds
memory limit per test:64 megabytes
input:standard input
output:standard output

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.

Examples
Input
2
5
1
Output
Alice
Bob

题目链接:http://codeforces.com/gym/100952/problem/G

题意:有一个容器里装着1-n n个数,A和B每次任意说一个数m,那么他要拿走容器里m的所有因子,如果谁拿空了容器,那么他输了,求先手赢还是后手赢

思路:只有1是后手赢,因为1只能拿一次,大于1的情况,假设a和b都不是聪明的,假设先手出x,后手出y,结果是后手赢,那么现在a和b都是聪明的,先手可以直接出x*y(即先手可以复制后手的操作,先手的操作可以包括后手的操作),则可以赢后手,所以大于1的情况一定是先手赢!

下面给出AC代码:

 #include <bits/stdc++.h>
using namespace std;
inline int read()
{
int x=,f=;
char ch=getchar();
while(ch<''||ch>'')
{
if(ch=='-')
f=-;
ch=getchar();
}
while(ch>=''&&ch<='')
{
x=x*+ch-'';
ch=getchar();
}
return x*f;
}
inline void write(int x)
{
if(x<)
{
putchar('-');
x=-x;
}
if(x>)
write(x/);
putchar(x%+'');
}
int main()
{
int T;
T=read();
while(T--)
{
int n;
n=read();
if(n>)
printf("Alice\n");
else printf("Bob\n");
}
return ;
}

Gym 100952G&&2015 HIAST Collegiate Programming Contest G. The jar of divisors【简单博弈】的更多相关文章

  1. Gym 100952E&&2015 HIAST Collegiate Programming Contest E. Arrange Teams【DFS+剪枝】

    E. Arrange Teams time limit per test:2 seconds memory limit per test:64 megabytes input:standard inp ...

  2. Gym 100952F&&2015 HIAST Collegiate Programming Contest F. Contestants Ranking【BFS+STL乱搞(map+vector)+优先队列】

    F. Contestants Ranking time limit per test:1 second memory limit per test:24 megabytes input:standar ...

  3. Gym 100952J&&2015 HIAST Collegiate Programming Contest J. Polygons Intersection【计算几何求解两个凸多边形的相交面积板子题】

    J. Polygons Intersection time limit per test:2 seconds memory limit per test:64 megabytes input:stan ...

  4. Gym 100952I&&2015 HIAST Collegiate Programming Contest I. Mancala【模拟】

    I. Mancala time limit per test:3 seconds memory limit per test:256 megabytes input:standard input ou ...

  5. Gym 100952H&&2015 HIAST Collegiate Programming Contest H. Special Palindrome【dp预处理+矩阵快速幂/打表解法】

    H. Special Palindrome time limit per test:1 second memory limit per test:64 megabytes input:standard ...

  6. Gym 100952D&&2015 HIAST Collegiate Programming Contest D. Time to go back【杨辉三角预处理,组合数,dp】

    D. Time to go back time limit per test:1 second memory limit per test:256 megabytes input:standard i ...

  7. Gym 100952C&&2015 HIAST Collegiate Programming Contest C. Palindrome Again !!【字符串,模拟】

    C. Palindrome Again !! time limit per test:1 second memory limit per test:64 megabytes input:standar ...

  8. Gym 100952B&&2015 HIAST Collegiate Programming Contest B. New Job【模拟】

    B. New Job time limit per test:1 second memory limit per test:64 megabytes input:standard input outp ...

  9. Gym 100952A&&2015 HIAST Collegiate Programming Contest A. Who is the winner?【字符串,暴力】

    A. Who is the winner? time limit per test:1 second memory limit per test:64 megabytes input:standard ...

随机推荐

  1. cell上添加倒计时,以及时差问题的解决

    原址 http://www.cnblogs.com/zhangmaliang/p/5102518.html 最近项目中用到了tableView的多个cell倒计时系统问题,本觉得很简单的一个事,一做发 ...

  2. linux系统下,安装centos7.0系统,配置网卡出现的问题(与centos5.x、centos6.x版本,有差异)

    1.新建虚拟机时,自己下载的是centos64系统,选择系统时,默认选择centos,而未选择centos64位,导致犯了一个低级错误,导致后面网卡安装一直有问题 2.查看ip命令与centos5.x ...

  3. Linux中dos2unix批量转换

    有时候遇到多层目录下的文件格式需要转换,dos2unix 没有-r之类的递归指令,所以需要与find还有管道结合. find -type f | xargs dos2unix -o

  4. 453. Minimum Moves to Equal Array Elements

    Given anon-emptyinteger array of sizen, find the minimum number of moves required to make all array ...

  5. 谈谈序列化—实体bean一定要实现Serializable接口?

    导读:最近在做项目的过程中,发现一个问题,就是我们最开始的时候,传递参数包括返回类型,都有map类型.但是由于map每次都要匹配key值,很麻烦.所以在之后就将参数传递和返回类型全都改成了实体bean ...

  6. HTTPS从认识到线上实战全记录

    前言 关于HTTPS,基本上你想知道的都在这里了.本文原标题<HTTPS原理与实践>,下图是本文配套PPT的目录截图: [TOC] 原理篇 认识HTTPS 先说一下,本文可能有些地方由于描 ...

  7. java inputstream to string stack overflow

    https://stackoverflow.com/questions/309424/read-convert-an-inputstream-to-a-string 过千赞的答案

  8. JavaScript的DOM编程--05--获取文本节点

    获取文本节点: 1). 步骤: 元素节点 --> 获取元素节点的子节点 2). 若元素节点只有文本节点一个子节点, 例如 <li id="bj" name=" ...

  9. 使用nginx 的反向代理 给 kibana加上basic的身份认证

    第一步准备工作 准备用户名密码: 更改host文件 第二步,安装nginx ubuntu安装Nginx之后的文件结构大致为:所有的配置文件都在/etc/nginx下,并且每个虚拟主机已经安排在了/et ...

  10. Python的伪私有属性

    什么是伪私有属性? 在Python中,没有类似 private 之类的关键字来声明私有方法或属性. Python中要声明私有属性,需要在属性前加上双下划线(但是结尾处不能有双下划线),如:self._ ...