cf C. Alice and Bob
http://codeforces.com/contest/347/problem/C
这道题就是求出n个数的最大公约数,求出n个数的最大值,总共有max1/gcd-n个回合。然后判断如果回合数%2==0 输出Bob,否则输出Alice。
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std; int main()
{
int max1=-;
int n;
int m;
while(scanf("%d",&n)!=EOF)
{
int x;
scanf("%d",&x);
max1=x;
m=x;
for(int i=; i<=n; i++)
{
scanf("%d",&x);
max1=max(max1,x);
m=__gcd(x,m);
}
int cnt=max1/m;
if((cnt-n)%==) printf("Bob\n");
else printf("Alice\n");
}
return ;
}
cf C. Alice and Bob的更多相关文章
- (中等) CF 585C Alice, Bob, Oranges and Apples,矩阵+辗转相除。
Alice and Bob decided to eat some fruit. In the kitchen they found a large bag of oranges and apples ...
- 2016中国大学生程序设计竞赛 - 网络选拔赛 J. Alice and Bob
Alice and Bob Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others) ...
- bzoj4730: Alice和Bob又在玩游戏
Description Alice和Bob在玩游戏.有n个节点,m条边(0<=m<=n-1),构成若干棵有根树,每棵树的根节点是该连通块内编号最 小的点.Alice和Bob轮流操作,每回合 ...
- Alice and Bob(2013年山东省第四届ACM大学生程序设计竞赛)
Alice and Bob Time Limit: 1000ms Memory limit: 65536K 题目描述 Alice and Bob like playing games very m ...
- sdutoj 2608 Alice and Bob
http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2608 Alice and Bob Time L ...
- hdu 4268 Alice and Bob
Alice and Bob Time Limit : 10000/5000ms (Java/Other) Memory Limit : 32768/32768K (Java/Other) Tota ...
- 2014 Super Training #6 A Alice and Bob --SG函数
原题: ZOJ 3666 http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3666 博弈问题. 题意:给你1~N个位置,N是最 ...
- ACdream 1112 Alice and Bob(素筛+博弈SG函数)
Alice and Bob Time Limit:3000MS Memory Limit:128000KB 64bit IO Format:%lld & %llu Submit ...
- 位运算 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 ...
随机推荐
- FJ省队集训DAY4 T3
#include<cstdio> #include<iostream> #include<cmath> #include<cstring> #inclu ...
- Android获取当前时间与星期几
public class DataString { private static String mYear; private static String mMonth; private static ...
- tag_on_failure => [] # prevent default _grokparsefailure tag on real records
[elk@zjtest7-frontend config]$ cat stdin04.conf input { stdin { } } filter { # drop sleep events gro ...
- translate函数说明
TRANSLATE(expr, from_string, to_string) from_string 与 to_string 以字符为单位,对应字符一一替换. SQL> SELECT TRAN ...
- 九度OJ 1437 To Fill or Not to Fill
题目大意:小明从杭州去往某目的地,要经过一些加油站,每个加油站的价格不一样.若能顺利到达,求加油费用最少为多少,否则求出能行驶的最远距离. 思路:贪心算法 1>若下一加油站的价格更便宜,则只需走 ...
- java 内存区域中的栈
有人说栈区存放引用,这种说法并不准确. public void Method1() { int i = 4; int y = 2; class1 cls1 = new class1(); } java ...
- 从有限状态机的角度去理解Knuth-Morris-Pratt Algorithm(又叫KMP算法)
转载请加上:http://www.cnblogs.com/courtier/p/4273193.html 在开始讲这个文章前的唠叨话: 1:首先,在阅读此篇文章之前,你至少要了解过,什么是有限状态机, ...
- centerOS安装chkrootkit
Chkrootkit是一个在本地系统检查rootkit痕迹的工具,它是检查系统二进制文件是否被rootkit病毒修改的一个shell脚本. (1)centerOS安装chkrootkit 安装gcc编 ...
- poj 1466 Girls and Boys(二分匹配之最大独立集)
Description In the second year of the university somebody started a study on the romantic relations ...
- Linux下PHP安装配置MongoDB数据库连接扩展
Web服务器: IP地址:192.168.21.127 PHP安装路径:/usr/local/php 实现目的: 安装PHP的MongoDB数据库扩展,通过PHP程序连接MongoDB数据库 具体操作 ...