Alice and Bob
求n个数的gcd 最后的数列必然是一个以gcd为首项,公差为gcd的等差数列
比如:2 4 6 显然结束
1 3 5 虽然也是等差数列,但还可以继续下去
所以这题的做法就是求n的数的gcd,然后就可以求出这个数列最长为多少,减掉初始的n
Code:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int, int>
#define mem(a, b) memset(a, b, sizeof(a));
#define lowbit(x) (x & -x)
#define lrt nl, mid, rt << 1
#define rrt mid + 1, nr, rt << 1 | 1
template <typename T>
inline void read(T& t) {
t = 0;
int f = 1;
char ch = getchar();
while (!isdigit(ch)) {
if (ch == '-')
f = -1;
ch = getchar();
}
while (isdigit(ch)) {
t = t * 10 + ch - '0';
ch = getchar();
}
t *= f;
}
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const ll Inf = 0x7f7f7f7f7f7f7f7f;
const int inf = 0x7f7f7f7f;
const double eps = 1e-5;
const double Pi = acos(-1);
const int maxn = 110;
int an[maxn];
int main(void) {
int n;
read(n);
for (int i = 1; i <= n; i++)
read(an[i]);
int k = an[1];
for (int i = 2; i <= n; i++)
k = __gcd(k, an[i]);
sort(an + 1, an + n + 1);
k = an[n] / k - n;
if (k & 1)
printf("Alice\n");
else
printf("Bob\n");
return 0;
}