Pagini recente » Cod sursa (job #3149642) | Cod sursa (job #1245942) | Cod sursa (job #2938984) | Cod sursa (job #1760574) | Cod sursa (job #1729436)
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm>
#include <bitset>
using namespace std;
ifstream fin("bowling.in");
ofstream fout("bowling.out");
const int dim = 101;
int sg[dim];
void precalcSG100(void) {
static bitset<dim + dim> used;
sg[0] = 0, sg[1] = 1, sg[2] = 2;
for (int i = 3; i <= 100; ++i) {
used.reset();
for (int j = 0; j < i; ++j)
used[sg[j] ^ sg[i - 1 - j]] = true;
for (int j = 0; j < i - 1; ++j)
used[sg[j] ^ sg[i - 2 - j]] = true;
for (int j = 0; j <= 200; ++j)
if (!used[i]) { sg[i] = j; break; }
}
}
inline int getSg(int x) {
return (x <= 80 ? sg[x] :sg[ 80 + (x - 80) % 12 ]);
}
int main() {
int testCount;
fin >> testCount;
precalcSG100();
for (; testCount; --testCount) {
int n; fin >> n;
int cur = 0, ans = 0;
for (int i = 1; i <= n; ++i) {
int x; fin >> x;
if (x == 1)
++cur;
else {
ans ^= getSg(cur);
cur = 0;
}
}
ans ^= getSg(cur);
fout << (ans ? "Nargy\n" : "Fumeanu\n");
}
return 0;
}
//Trust me, I'm the Doctor!