Codeforces Round #201 (Div. 2) - C. Alice and Bob
题目链接:http://codeforces.com/contest/347/problem/C
题意是给你一个数n,然后n个数,这些数互不相同。每次可以取两个数x和y,然后可以得到|x - y|这个数,要求不在这个数组中,然后添加进去,直到不能取为止,不能取的人输了。Alice先取,求谁最后能赢。
可以先列举几种情况,可以发现,一般情况取到最后剩下1~max这些数了。但是要是比如原来的数有3 12这两个数,那最后就会剩下3 6 9 12这4个数,由此可以看出这种情况下剩下的一定是原来数的gcd的倍数,所以答案就是Max/gcd - n。
- #include <iostream>
- using namespace std;
- int a[];
- int gcd(int x , int y) {
- if(!y) return x;
- return gcd(y , x % y);
- }
- int main()
- {
- int n , temp , Max = -;
- cin >> n;
- for(int i = ; i <= n ; i++) {
- cin >> a[i];
- Max = max(Max , a[i]);
- }
- temp = gcd(a[] , a[]);
- for(int i = ; i <= n ; i++)
- temp = gcd(temp , a[i]);
- if((Max / temp - n) & )
- cout << "Alice\n";
- else
- cout << "Bob\n";
- }
Codeforces Round #201 (Div. 2) - C. Alice and Bob的更多相关文章
- Codeforces Round #201 (Div. 2)C,E
数论: C. Alice and Bob time limit per test 2 seconds memory limit per test 256 megabytes input standar ...
- codeforce Codeforces Round #201 (Div. 2)
cf 上的一道好题: 首先发现能生成所有数字-N 判断奇偶 就行了,但想不出来,如何生成所有数字,解题报告 说是 所有数字的中最大的那个数/所有数字的最小公倍数,好像有道理:纪念纪念: #incl ...
- Codeforces Round #593 (Div. 2) D. Alice and the Doll
题目:http://codeforces.com/problemset/problem/1236/D思路:机器人只能按照→↓←↑这个规律移动,所以在当前方向能够前进的最远处即为界限,到达最远处右转,并 ...
- Codeforces Round #201 (Div. 2). E--Number Transformation II(贪心)
Time Limit:1000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u Description You ar ...
- Codeforces Round #533 (Div. 2)题解
link orz olinr AK Codeforces Round #533 (Div. 2) 中文水平和英文水平都太渣..翻译不准确见谅 T1.给定n<=1000个整数,你需要钦定一个值t, ...
- Codeforces Round #557 (Div. 1) 简要题解
Codeforces Round #557 (Div. 1) 简要题解 codeforces A. Hide and Seek 枚举起始位置\(a\),如果\(a\)未在序列中出现,则对答案有\(2\ ...
- Codeforces Round #633 (Div. 2)
Codeforces Round #633(Div.2) \(A.Filling\ Diamonds\) 答案就是构成的六边形数量+1 //#pragma GCC optimize("O3& ...
- Codeforces Round #721 (Div. 2)A. And Then There Were K(位运算,二进制) B1. Palindrome Game (easy version)(博弈论)
半个月没看cf 手生了很多(手动大哭) Problem - A - Codeforces 题意 给定数字n, 求出最大数字k, 使得 n & (n−1) & (n−2) & ...
- Codeforces Round #366 (Div. 2) ABC
Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...
随机推荐
- TCSRM 591 div2(1000)(dp)
挺好的dp 因为有一点限制 必须任意去除一个数 总和就会小于另一个总和 换句话来说就是去除最小的满足 那么就都满足 所以是限制最小值的背包 刚开始从小到大定住最小值来背 TLE了一组数据 后来发现如果 ...
- hdu 1559 最大子矩阵 (简单dp)
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1559 #include <cstring> #include <cstdlib> ...
- UVa 11178 (简单练习) Morley's Theorem
题意: Morley定理:任意三角形中,每个角的三等分线,相交出来的三个点构成一个正三角形. 不过这和题目关系不大,题目所求是正三角形的三个点的坐标,保留6位小数. 分析: 由于对称性,求出D点,EF ...
- android开发中eclipse里xml开发的自动提示和使用帮助快捷键提示
Eclipse Android 代码自动提示功能 Eclipse for android 设置代码提示功能 打 开 Eclipse 依次选择 Window > Preferences > ...
- 缺少编译器要求的成员“System.Runtime.CompilerServices.ExtensionAttribute..ctor” 解决方案
我自己使用的解决方法 错误产生环境及非完美解决办法 错误提示:缺少编译器要求的成员"System.Runtime.CompilerServices.ExtensionAttribute..c ...
- [转] Jquery滚动加载
原文地址:http://hi.baidu.com/vipxiaofan/item/9eb927b795671f77254b0985 另外一个asp.net的例子:http://blog.csdn.ne ...
- linux 服务自动调用
php服务地址: http://192.168.2.117/web/index.php/buy/auctionselect 编写脚本service.sh,内容: #! /bin/sh crul htt ...
- apache开源项目 -- tomee
Apache TomEE,发音是“Tommy”,是一个经Apache.JavaEE6.Web框架认证的适配器,其在Tomcat服务器中是最强大的.Apache TomEE是由香草项目(简化常见编程任务 ...
- h.264码流解析_一个SPS的nalu及获取视频的分辨率
00 00 00 01 67 42 00 28 E9 00 A0 0B 77 FE 00 02 00 03 C4 80 00 00 03 00 80 00 00 1A 4D 88 10 94 0 ...
- Android SDK Manager 更新代理配置 ,蛋碎了
启动 Android SDK Manager ,打开主界面,依次选择「Tools」.「Options...」,弹出『Android SDK Manager - Settings』窗口: 在『Andro ...