CodeForces
来源:互联网 发布:主宰西游淘宝 编辑:程序博客网 时间:2024/06/14 03:02
CodeForces - 347C
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).
Example
Input
22 3OutputAliceInput25 3OutputAliceInput35 6 7OutputBob
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.
#include <cstdio>#include <iostream>#include <algorithm>using namespace std;int gcd(int m,int n) { while (n != 0) { int t = m % n; m = n; n = t; } return m; }int main(){ int n; int a[110]; scanf("%d",&n); scanf("%d%d",&a[0],&a[1]); if (a[0]>a[1]){ int t=a[0]; a[0]=a[1]; a[1]=t; } int k=gcd(a[1],a[0]); for (int i=2;i<n;i++){ scanf("%d",&a[i]); int m=a[i]; if (k>m){ int tt=m; m=k; k=tt; } k=gcd(m,k); } sort(a,a+n); int ss=a[n-1]/k; int xx=ss-n; if (xx%2!=0){ printf("Alice\n"); } else{ printf("Bob\n"); } return 0;}
阅读全文
0 0
- codeforces~~~
- Codeforces
- codeforces
- Codeforces
- codeforces
- codeforces
- Codeforces
- Codeforces
- CodeForces
- CodeForces
- CodeForces
- CodeForces
- CodeForces
- Codeforces
- Codeforces
- Codeforces
- Codeforces
- Codeforces
- HDU 3746 Cyclic Nacklace KMP求字符串最小循环节长度
- Android View触摸事件传递机制 一
- Docker 入门
- UESTC 1638 红藕香残玉簟秋,轻解罗裳,独上兰舟。
- 小白webpack学习之路
- CodeForces
- Python3 PyQt5 pycharm 环境搭建,pyqt5教程
- 100. Same Tree
- VS2010中仅一次配置opencv的方法
- 换位思考多周期约束
- 图解集合 3 : CopyOnWriteArrayList
- Python基础-枚举
- 状态模式
- Java设计模式:九、生成器模式