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. C语言宏定义技巧——多次包括头文件内容不同

    1.  头文件定义例如以下: /* declears in "funcs.h" */ FUNC_1(ID_FUN1_001) FUNC_1(ID_FUN1_002) FUNC_2( ...

  2. Yelp面试题目

    题目:FizzBuzz 从stdin得到数字N(<10^7),然后从打印出从1到N的数字.输出到stdout,假设数字是3的倍数的话就仅仅打印"Buzz",假设数字是5的倍数 ...

  3. SQL面试练习(MySql)

    创建测试数据库: /*如果已经存在此数据库,先删除*/ drop database if exists sqltest ; /*创建并设置编码为UTF-8*/ create database sqlt ...

  4. 常用DOS下MSC指令

    xp:copy C:\WINDOWS\repair\*.* 到 c:\windows\system32\config 2k: copy C:\winnt\repair\*.* 到 c:\winnt\s ...

  5. mac下配置eclipse的maven环境

    转自:http://www.cnblogs.com/yqskj/archive/2013/03/30/2990292.html 1.下载maven的bin包,解压,配置到环境变量里面去 1). 首先到 ...

  6. TC SRM 582 DIV 2

    Rating又跌了,第二个题,没想好就乱开始乱写了.. 我写乱搞贪心,没过...如果总人数很多judge函数写的不好,DIV2数据很水,直接暴力就行. #include <cstring> ...

  7. asp.net+access实现DropDownList与RadDatePicker同步筛选

    这里没有使用SqlServer是因为老师要求使用access. 前台代码 <table style="margin:auto"> <tr><td cl ...

  8. 使用jsoncpp解析生成json

    在此站点下载jsoncpp(https://sourceforge.net/projects/jsoncpp/这个站点的版本较旧) 在电脑上安装Python,运行amalgamate.py,生成的di ...

  9. [TJOI2017] 不勤劳的图书管理员

    题目描述 加里敦大学有个帝国图书馆,小豆是图书馆阅览室的一个书籍管理员.他的任务是把书排成有序的,所以无序的书让他产生厌烦,两本乱序的书会让小豆产生这两本书页数的和的厌烦度.现在有n本被打乱顺序的书, ...

  10. Hive Metastore

    metastore:实际保存表信息的地方.     包括: 数据库,表的基本信息:权限信息:存储格式信息:                 各种属性信息:                 权限信息: ...