题干:

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.

题目大意:

给你一个数的序列,定义一种操作:任选两个不同的数,将他们的差的绝对值加入序列中(注意操作中不涉及删除元素)。问你需要多少次操作可以操作到无法操作,如果操作次数是奇数 那就Alice赢,偶数就Bob赢,让你输出最后谁获得胜利。

解题报告:

其实原题干不是这么写的,,原题看起来像是个博弈问题,,但是其实分析以后不难发现,其实就是个操作次数的奇偶问题。(其实也可能是可以证明,给定一个初始序列之后,那么操作次数就已经固定了,我们只需要求出这个数是奇数还是偶数就可以了。)

分析到这一步,然后我们从结果入手,结果序列一定是不能再操作的,我们假设这个序列是个递增序列的话(其实他加这个绝对值的原因就是告诉你:你可以把这个序列当成一个递增序列去看,,因为他添加数了啊也没说添加到哪里,如果默认添加到最后,那么这个序列肯定就不是一个递增序列了,所以他说有绝对值,就是为了让你把它当成一个排好序的递增的),那么我们任意两项的差都在这个序列中,也就是说这个数列一定是一个等差数列,并且排好序后的最大项一定是an,那么我们能得到的最小值是多少呢?根据求gcd的原理我们知道,两个数相减,得到的一定是两个数的gcd的倍数。根据这个原理,我们知道最小的数一定是这n个数的gcd,求值,也就是最终序列的a[1]。现在我们有了最终序列的a[1]和a[all],现在要求一共操作了多少次才变成这个序列。因为每一次操作只增加一个元素,那么增加了多少个元素,肯定就操作了多少次呗。那么增加了多少个元素呢?最终序列元素个数为all,初始序列为n个,那作差就是答案啊。然后判断这个答案的奇偶性就可以了。

AC代码:

#include<cstdio>
#include<iostream>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<set>
#include<string>
#include<cmath>
#include<cstring>
#define ll long long
#define pb push_back
#define pm make_pair
#define fi first
#define se second
using namespace std;
const int MAX = 2e5 + 5;
int a[MAX];
int main()
{int n;cin>>n;for(int i = 1; i<=n; i++) scanf("%d",a+i);sort(a+1,a+n+1);int g = a[1];for(int i = 2; i<=n; i++) g = __gcd(a[i],g);int tmp = a[n]/g - n;if(tmp&1) puts("Alice");else puts("Bob");return 0 ;}

【CodeForces - 347C 】Alice and Bob (思维,数学,等差数列)相关推荐

  1. CodeForces - 346A Alice and Bob(数论+博弈)

    题目链接:点击查看 题目大意:初始时给出n个数组成的集合,现在要求爱丽丝和鲍勃两人轮流按照规则操作,无法操作的一方即为输,本游戏的规则就是,在集合中任意选择两个数x和y,计算(x-y)的绝对值,若该绝 ...

  2. Sicily1798. Alice and Bob[策略问题]

    [原题描述] Description Bob is very famous because he likes to play games. Today he puts a chessboard in ...

  3. HDU4268 2012ACM长春赛区网络赛 Alice and Bob

    题目:HDU4268(贪心) 题意是Alice和Bob都有N张卡片,卡片各有尺寸,Alice拿自己的卡片分别去盖Bob的,给出每张卡片的尺寸,问最多可以盖住多少张. 先说一下我错误的解题方法,主要思想 ...

  4. SDUT2608(Alice and Bob)

    题目描述 Alice and Bob like playing games very much.Today, they introduce a new game. There is a polynom ...

  5. NYOJ 1053 Alice and Bob (N)

    Alice and Bob (N) 时间限制:1000 ms  |  内存限制:65535 KB 难度:2 描述 也不知道是谁规定的,Alice 和 Bob总是有一堆做不完的事,和一堆奇葩想法,而且重 ...

  6. NYOJ练习题 又见Alice and Bob

    又见Alice and Bob 时间限制:1000 ms  |  内存限制:65535 KB 描述 集训生活如此乏味,于是Alice和Bob发明了一个新游戏.规则如下:首先,他们得到一个集合包含n个特 ...

  7. 牛客 - Alice and Bob(尺取+二分)

    题目链接:点击查看 题目大意:给出一个长度为 nnn 的数列,和一个数字 kkk.现在给出 mmm 次询问,每次查询需要回答区间 [l,r][l,r][l,r] 内有多少个子区间,满足区间内不同的数字 ...

  8. 2021牛客暑期多校训练营1 A.Alice and Bob 博弈 SG函数

    传送门 文章目录 题意: 思路: 题意: 有两堆石子,两个人每次可以进行如下操作:从某一堆狮子中拿出x(x>0)x(x>0)x(x>0)个,从另一堆石子中拿出s∗x(s>=0) ...

  9. Alice and Bob

    Alice and Bob 题意: 两人博弈,每次一个人从一堆中拿k个,同时从另一堆拿k * s(s>=0)个,问谁先不能拿 10000组数据,N<=5000 题解: (x,y)表示第一堆 ...

最新文章

  1. 东北师大计算机考研报名人数,东北师范大学考研难吗?一般要什么水平才可以进入?...
  2. 计算机教师简介50字,教师风采个人简介50字数.docx
  3. phpcmsv9多表联合查询分页功能实现
  4. 云计算技术 — 容灾备份技术
  5. 理解和配置Out of memory: Kill process
  6. 深度学习(一)——MP神经元模型, BP算法, 神经元激活函数, Dropout
  7. 就算忘了自己也忘不了你
  8. 使用ConnectivityManager 判断网络是否连接
  9. linux查看进程加载了哪些dll,linux下动态链接库的加载及解析过程
  10. 离职阿里4年后,我给年轻人的7点建议
  11. 多次字符串相加一定要用StringBuilder而不用 + 吗?
  12. EDA技术实用教程 | 复习十四 | Quartus II工具的使用
  13. sql代码格式化_使用SQL格式化程序选项管理SQL代码格式化
  14. pe系统测试软件,PE实测:测试环境及PE制作
  15. c语言辗转求最小公倍数,c语言:辗转相除法求最大公约数、最小公倍数
  16. MySQL之Explain
  17. 华为、华三交换机查看光模块收发光及光模块信息
  18. 计算机网络故障提出问题,列控系统及其计算机网络的故障诊断与故障容错研究...
  19. 朝花夕拾 —— 重温《花田半亩》
  20. android 重力感应切换屏幕,Android 重力感应和屏幕旋转关系

热门文章

  1. log双线性模型log-bilinear model简单概括
  2. linux 安装qq,如何安装linux版本QQ?
  3. linux ubantu扩展空间,ubuntu 扩展存储空间
  4. jquery查找ul属性不是hide,jQuery的ul显示/隐藏功能
  5. java socketchannel api,SocketChannel API
  6. c++获取时间戳_时间简史
  7. nginx 根证书 服务器证书,Nginx双向证书校验(服务器验证客户端证书)
  8. PCI总线体系结构概述
  9. Linux内核的中断机制
  10. java arraylist范围_Java常见集合之ArrayList深入分析