codeforce Codeforces Round #201 (Div. 2)

cf 上的一道好题;  首先发现能生成所有数字-N 判断奇偶 就行了,但想不出来,如何生成所有数字,解题报告 说是  所有数字的中最大的那个数/所有数字的最小公倍数,好像有道理;纪念纪念;

#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;

int arr[112];
int gcd( int a,int b ){
  if( b == 0 )return a;
  else return gcd( b,a%b );
}
int main( )
{
    int N;
    while( scanf("%d",&N) != EOF )
    {
        for( int i = 1; i <= N; i++ ){
            scanf("%d",&arr[i]);
        }
        sort( &arr[1],&arr[1]+N );
        int t = arr[1];
        for( int i = 2; i <= N; i++ )
        t = gcd( t,arr[i] );
        N = arr[N]/t - N;
        if( N%2 )puts("Alice");
        else puts("Bob");
    }
    return 0;
}

  

原文地址:https://www.cnblogs.com/wulangzhou/p/3333090.html