Pagini recente » Borderou de evaluare (job #1117392) | Cod sursa (job #970891) | Borderou de evaluare (job #1479551) | Borderou de evaluare (job #1125154) | Cod sursa (job #2690899)
#include <bits/stdc++.h>
using namespace std;
const int Vmax = 3e5;
int sg[Vmax + 5];
void precompute() {
int sg_val = 0;
for (int i = 2; i <= Vmax; ++i)
if (!sg[i]) {
sg[i] = ++sg_val;
for (int j = i + i; j <= Vmax; j += i)
if (!sg[j]) sg[j] = sg_val;
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
ifstream cin("cmmdcgame.in");
ofstream cout("cmmdcgame.out");
precompute();
int t, n, x, xor_sum;
cin >> t;
while (t--) {
xor_sum = 0;
cin >> n;
for (int i = 1; i <= n; ++i) {
cin >> x;
xor_sum ^= sg[x];
}
cout << (xor_sum ? "D\n" : "J\n");
}
return 0;
}