time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

 

It is so boring in the summer holiday, isn't it? So Alice and Bob have invented a new game to play. The rules are as follows. First, they get a set of n distinct integers. And then they take turns to make the following moves. During each move, either Alice or Bob (the player whose turn is the current) can choose two distinct integers x and y from the set, such that the set doesn't contain their absolute difference |x - y|. Then this player adds integer |x - y| to the set (so, the size of the set increases by one).

If the current player has no valid move, he (or she) loses the game. The question is who will finally win the game if both players play optimally. Remember that Alice always moves first.

Input

The first line contains an integer n (2 ≤ n ≤ 100) — the initial number of elements in the set. The second line contains n distinct space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the elements of the set.

Output

Print a single line with the winner's name. If Alice wins print "Alice", otherwise print "Bob" (without quotes).

Examples
input
2
2 3
output
Alice
input
2
5 3
output
Alice
input
3
5 6 7
output
Bob
Note

Consider the first test sample. Alice moves first, and the only move she can do is to choose 2 and 3, then to add 1 to the set. Next Bob moves, there is no valid move anymore, so the winner is Alice.

起初一眼以为是一道博弈问题,后来发现就是一个GCD();

求出GCD();后即可做倍数。

注意最后要-n

附AC代码:

 #include<bits/stdc++.h>
using namespace std; int gcd(int a, int b)
{
return (b>)?gcd(b,a%b):a;
} int main()
{
int n, a[], i;
cin>>n;
int Max = ;
for(i = ; i < n; i++)
{
cin>>a[i];
if(a[i] > Max)
Max = a[i];
}
int p = a[];
for(i = ; i < n; i++)
p = gcd(p, a[i]);
int ans = Max/p - n;
printf(ans& ? "Alice\n" : "Bob\n");
return ;
}

E - Alice and Bob的更多相关文章

  1. 2016中国大学生程序设计竞赛 - 网络选拔赛 J. Alice and Bob

    Alice and Bob Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) ...

  2. bzoj4730: Alice和Bob又在玩游戏

    Description Alice和Bob在玩游戏.有n个节点,m条边(0<=m<=n-1),构成若干棵有根树,每棵树的根节点是该连通块内编号最 小的点.Alice和Bob轮流操作,每回合 ...

  3. Alice and Bob(2013年山东省第四届ACM大学生程序设计竞赛)

    Alice and Bob Time Limit: 1000ms   Memory limit: 65536K 题目描述 Alice and Bob like playing games very m ...

  4. sdutoj 2608 Alice and Bob

    http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2608 Alice and Bob Time L ...

  5. hdu 4268 Alice and Bob

    Alice and Bob Time Limit : 10000/5000ms (Java/Other)   Memory Limit : 32768/32768K (Java/Other) Tota ...

  6. 2014 Super Training #6 A Alice and Bob --SG函数

    原题: ZOJ 3666 http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3666 博弈问题. 题意:给你1~N个位置,N是最 ...

  7. ACdream 1112 Alice and Bob(素筛+博弈SG函数)

    Alice and Bob Time Limit:3000MS     Memory Limit:128000KB     64bit IO Format:%lld & %llu Submit ...

  8. 位运算 2013年山东省赛 F Alice and Bob

    题目传送门 /* 题意: 求(a0*x^(2^0)+1) * (a1 * x^(2^1)+1)*.......*(an-1 * x^(2^(n-1))+1) 式子中,x的p次方的系数 二进制位运算:p ...

  9. SDUT 2608:Alice and Bob

    Alice and Bob Time Limit: 1000ms   Memory limit: 65536K  有疑问?点这里^_^ 题目描述 Alice and Bob like playing ...

  10. Alice and Bob(贪心HDU 4268)

    Alice and Bob Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Tota ...

随机推荐

  1. spring工具类获取bean

    import org.springframework.web.context.ContextLoader; import org.springframework.web.context.WebAppl ...

  2. Python基础语法06--文件

    Python 文件I/O 本章只讲述所有基本的的I/O函数,更多函数请参考Python标准文档. 打印到屏幕 最简单的输出方法是用print语句,你可以给它传递零个或多个用逗号隔开的表达式.此函数把你 ...

  3. django的form验证机制

    今天遇到了一个奇怪的问题,django中formview一直返回200,但是却没有执行form_valid方法,然后在其中加了一个form_invalid方法: class StudentRegist ...

  4. SolidEdge 如何由装配图快速生成爆炸视图

    建立图纸精灵,组态中选择explode(没有下一步可选了)   点击完成即可绘制爆炸图

  5. [iOS]APP代码实践:建立一个辅助的APP类,降低对AppDelegate的改动

    郝萌主倾心贡献.尊重作者的劳动成果,请勿转载. [UIApplication sharedApplication].delegate 可是时间长了还是认为这样不太好,AppDelegate本身有其自己 ...

  6. 新生入学V3.0颗粒归仓

    新生入学系统V3.0接近尾声.每次做项目都有不一样的收获.V1.0,V2.0主要是熟悉了整个项目流程是怎样进行的,可行性分析--需求分析(原型图Axure)--实体设计(PD)--类图时序图(EA)- ...

  7. ViewPagerIndicator 取代TabHost,实现滑动tab,引导页等效果

    https://github.com/eltld/ViewPagerIndicator 取代TabHost,实现滑动tab,引导页等效果

  8. (转)gcc学习笔记

    1.gcc -Wall hello.c -o hello //编译源文件,显示警告信息 2../a.out   //运行程序 3.gcc -Wall calc.c /usr/lib/libm.a -o ...

  9. 【网络协议】IP协议、ARP协议、RARP协议

    IP数据报 IP是TCP/IP协议族中最核心的协议,全部的TCP.UDP.ICMP.IGMP数据都以IP数据报的格式传输.IP仅提供尽力而为的传输服务.假设发生某种错误.IP会丢失该数据.然后发送IC ...

  10. javascript常用事件及方法

    1.获取鼠标坐标,考虑滚动条拖动 var e = event || window.event; var scrollX = document.documentElement.scrollLeft || ...