cf C. Alice and Bob

http://codeforces.com/contest/347/problem/C

这道题就是求出n个数的最大公约数,求出n个数的最大值,总共有max1/gcd-n个回合。然后判断如果回合数%2==0 输出Bob,否则输出Alice。

 1 #include <cstdio>

 2 #include <cstring>

 3 #include <algorithm>

 4 using namespace std;

 5 

 6 int main()

 7 {

 8     int max1=-1;

 9     int n;

10     int m;

11     while(scanf("%d",&n)!=EOF)

12     {

13         int x;

14         scanf("%d",&x);

15         max1=x;

16         m=x;

17         for(int i=2; i<=n; i++)

18         {

19             scanf("%d",&x);

20             max1=max(max1,x);

21             m=__gcd(x,m);

22         }

23         int cnt=max1/m;

24         if((cnt-n)%2==0) printf("Bob\n");

25         else printf("Alice\n");

26     }

27     return 0;

28 }
View Code

 

你可能感兴趣的:(ICE)