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. JavaScript类型比较

    JavaScript的类型 原始类型: number string boolean null undefined 对象类型: Object function Array Date ... 隐式转换 + ...

  2. JAVA中的集合与排序

    一:常见的集合类 Collection接口  和   Map接口 Collection ①:collection是最常见的集合的上级接口. ②:继承自collection的常用接口有List,Set, ...

  3. MySQL 如何存储长度较大的varchar与blob

    本文同时发表在https://github.com/zhangyachen/zhangyachen.github.io/issues/96 最近,在工作中遇到了MySQL中如何存储长度较长的字段类型问 ...

  4. Asp.net常用开发方法之DataTable/DataReader转Json格式代码

    public static string JsonParse(OleDbDataReader dataReader) //DataRead转json { StringBuilder jsonStrin ...

  5. Xamarin Android 中Acitvity如何传递数据

    在xamarin android的开发中,activity传递数据非常常见,下面我也来记一下在android中activity之间传递数据的几种方式, Xamarin Android中Activity ...

  6. 对于group by 和 order by 并用 的分析

    今天朋友问我一个sql查询. 需求是 找到idapi最近那条数据,说明idapi 是重复的,于是就简单的写了 SELECT * FROM `ag_alarm_history`   group by ` ...

  7. 解决openssh漏洞,升级openssh版本

    关于解决漏洞的问题我就不详说了,主要就是升级版本.这里我们就直接简单记录下步骤: 1.升级 使用root用户登录系统进入到/home/guankong ,上传openssh-6.6p1.tar.gz到 ...

  8. java环境配置教程jde,jre

    控制面板--所有控制面板项--系统--高级系统设置--环境变量 JAVA_HOME = D:\java\jdk CLASSPATH = .;%JAVA_HOME%\lib;%JAVA_HOME%\li ...

  9. base64格式图片转换为FormData对象进行上传

    原理:理由ArrayBuffer.Blob和FormData var base64String = /*base64图片串*/; //这里对base64串进行操作,去掉url头,并转换为byte va ...

  10. php 理解

    <?php class t { var $num; var $dynamic_function; public function dynamic_function() { $func = $th ...