Codeforces Round #201 (Div. 1) A. Alice and Bob(数学)
来源:互联网 发布:俊平大魔王知乎 编辑:程序博客网 时间:2024/06/14 06:18
题目地址:http://codeforces.com/problemset/problem/346/A
思路:最终无法再选择两个数,说明最后形成了一个公差为d的等差数列,即为d,d+d,d+2*d,……,d+(n-1)*d 。所以,只需求出原始数列所有数的最大公约数即可求出公差。最终数列元素个数=数列元素最大值/公差,减去n即为比赛过程中新增加的元素。由于A先开始游戏,所以如果新增加元素为奇数则A赢,否则B赢。
#include<cstdio>#include<cstring>#include<iostream>#include<algorithm>using namespace std;int n,a[150];int main(){ scanf("%d",&n); for(int i=0;i<n;i++) scanf("%d",&a[i]); int gcd=a[0],maxx=a[0]; for(int i=1;i<n;i++) { gcd=__gcd(gcd,a[i]); maxx=max(maxx,a[i]); } int step=maxx/gcd-n; printf("%s\n",step&1?"Alice":"Bob"); return 0;}
0 0
- Codeforces Round #201 (Div. 1) A. Alice and Bob(数学)
- Codeforces Round #201 (Div. 2) C. Alice and Bob ( 数学
- Codeforces Round #201 (Div. 1) / 346A Alice and Bob (数论&想法题)
- Codeforces Round #201 (Div. 2) C. Alice and Bob
- [CodeForces 346A]Alice and Bob[数学]
- Codeforces Round #201 (Div. 2) 347C Alice and Bob(脑洞)
- codeforces 347 c Alice and Bob(博弈 && 数学)
- codeforces-346A-Alice and Bob【数论】
- CodeForces 346A Alice and Bob
- CodeForces 346A Alice and Bob
- Codeforces Beta Round #6 (Div. 2 Only) C. Alice, Bob and Chocolate
- Codeforces Round #325 (Div. 2) E. Alice, Bob, Oranges and Apples
- Alice and Bob (CodeForces
- Alice and Bob CodeForces
- HDU 5054 Alice and Bob(数学)
- A:Alice and Bob
- Codeforces Round #305 (Div. 1) A. Mike and Frog(数学)
- Codeforces Round #6——C. Alice, Bob and Chocolate(想法题)
- HDU 1003
- 关于输入流(从硬盘文件输入到程序中)
- Hdu1024 开门人和关门人(结构体排序)
- 2016.7.26 随记
- line-height 和 vertical-align 行高与行对齐精解 (图文)
- Codeforces Round #201 (Div. 1) A. Alice and Bob(数学)
- 公路乘车(完全背包)
- express,使用session进行身份认证
- C fork introduce
- Java多线程面试题
- find 源码剖析
- C++ - PAT - 1053. 住房空置率 (20)
- Session存储方式和配置
- HDU 4432Sum of divisors (进制转换模板)