Algorithm
Code Examples
#1 Code Example with C++ Programming
Code -
C++ Programming
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, mx = 0, gcd = 0;
cin >> n;
for(int i = 0, tmp; i < n; ++i)
cin >> tmp, mx = max(mx, tmp), gcd = __gcd(gcd, tmp);
mx /= gcd;
if((mx - n) % 2 == 0)
puts("Bob");
else
puts("Alice");
return 0;
}
Copy The Code &
Try With Live Editor
Input
2
2 3
2 3
Output
Alice
Demonstration
Codeforces Solution-Alice and Bob-Solution in C, C++, Java, Python