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 ;
}

最新文章

  1. 三种执行SQL语句的的JAVA代码
  2. 2016春招Android开发实习生(网易传媒)笔试
  3. 当Editplus遇到Java的Scanner
  4. 【java】Servlet 工程 web.xml 中的 servlet 和 servlet-mapping 标签
  5. MyBatis-Generator 逆向工程(生成异常缺少部分的方法)
  6. AngularJS入门第一课
  7. python requests库学习笔记(上)
  8. [POI2007]ZAP-Queries
  9. mui预加载
  10. Debian9安装后的一些配置
  11. TextView不用ScrollViewe也可以滚动的方法
  12. MySQL Error--Error Code
  13. 前端异常监控 - BadJS
  14. MATLAB:读取txt文件中物体的三维坐标,显示三维模型
  15. 【github】添加 ssh 秘钥
  16. 【cs229-Lecture2】Gradient Descent 最小二乘回归问题解析表达式推导过程及实现源码(无需迭代)
  17. Linux其他:环境变量配置
  18. MySQL数据库索引(上)
  19. 【原】解决Debug JDK source 无法查看局部变量的问题方案(重新编译rt.jar包)
  20. iozone文件系统测试工具在AM335x上的移植

热门文章

  1. 【java设计模式】责任链模式
  2. 【java】java.util.regex.Pattern和java.util.regex.Matcher简单示例
  3. The Movie db (TMDB)的API申请
  4. Jstree 使用CheckBox插件 选中父节点时被禁用的子节点也会选中问题
  5. MySQL in or效率对比
  6. 安装MongoDB步骤
  7. Python学习(四):模块入门
  8. 3.Nginx常用功能介绍
  9. Python学习_01_对象
  10. 客户端 未登录页面 (clearfix 分割线)