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. 【hibernate/JPA】注解方式实现 复合主键【spring boot】

    1>hibernate/JPA实现复合主键的思路:是将所有的主键属性封装在一个主键类中,提供给需要复合主键的实体类使用. 2>主键类的几点要求: . 使用复合主键的实体类必须实现Seria ...

  2. 【java】java 中 byte[]、File、InputStream 互相转换

    ========================================================================= 使用过程中,一定要注意close()掉各个读写流!! ...

  3. remove_if的问题

    #include<iostream> #include<list> #include<algorithm> #include"PRINT_ELEMENTS ...

  4. Printing multipage output

    Printing known-length multipage output Using the PrintDataGrid control for multipage grids Example: ...

  5. Python源代码--整数对象(PyIntObject)的内存池

    [背景] 原文链接:http://blog.csdn.net/ordeder/article/details/25343633 Python整数对象是不可变对象,什么意思呢?比如运行例如以下pytho ...

  6. 线程池实例:使用Executors和ThreadPoolExecutor

    线程池负责管理工作线程,包含一个等待执行的任务队列.线程池的任务队列是一个Runnable集合,工作线程负责从任务队列中取出并执行Runnable对象. java.util.concurrent.ex ...

  7. ArcGIS教程:分水岭

    摘要 确定栅格中一组像元之上的汇流区域. 使用方法 · 各个分水岭的值将取自输入栅格中源的值或者要素倾泻点数据.假设倾泻点为栅格数据集,则使用像元值.假设倾泻点为点要素数据集,则从指定的字段中获取值. ...

  8. OpenWrt inittab

    OpenWrt 启动时会执行 rc.d/ 下的脚本. 这篇文章 介绍了启动脚本里的规则. K50dropbear -> ../init.d/dropbear K85odhcpd -> .. ...

  9. CentOS挂载优盘

    插入优盘前: [root@centOS5 mnt]# fdisk -l Disk /dev/hdd: bytes heads, sectors/track, cylinders Units = cyl ...

  10. Devices下设备的进程显示为问号的问题

     adb shell getprop ro.debuggable      返回  ro.debuggable=0     说明这个机子的版本不是userdebug版本,是user版本     只有这 ...