2015-06-27 14:19:45

传送门

总结:虚拟参赛的一场,题目都很有质量!比的不是很好,rank540+

  赛后补到第三题。

 

A题:数学

  题意:给出 n (n<=100)个互不相同的数的集合,Alice 和 Bob 轮流进行操作,每次操作取出任意两个数,将他们差的绝对值加入集合(注意,这个绝对值一定不能已经在集合中),不能操作的人输。

  思路:仔细思考会发现大部分的集合操作到最后都是 1,2,3... maxval,maxval是指原来集合中的最大值。但是有那么几种,比如 3 9 12 操作到最后是 3 6 9 12,其实只要求出原来集合中所有数的gcd,操作到最后集合一定是:gcd,2*gcd,....,maxval,本质其实就是数的拆分的过程,知道这个结论后就可以做咯。

#include <cstdio>
#include <ctime>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;

#define getmid(l,r) ((l) + ((r) - (l)) / 2)
#define MP(a,b) make_pair(a,b)
#define PB(a) push_back(a)

typedef long long ll;
typedef pair<int,int> pii;
const double eps = 1e-8;
const int INF = (1 << 30) - 1;
const int MAXN = 110;

int n,A[MAXN];

int main(){
    int tmax = 0,G;
    scanf("%d",&n);
    for(int i = 1; i <= n; ++i){
        scanf("%d",&A[i]);
        tmax = max(tmax,A[i]);
        if(i == 1) G = A[1];
        else G = __gcd(G,A[i]);
    }
    int cnt = tmax / G - n;
    if(cnt & 1) printf("Alice\n");
    else printf("Bob\n");
    return 0;
}
View Code

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-12
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-08-11
  • 2021-08-20
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案