Pagini recente » Cod sursa (job #441605) | Cod sursa (job #92039) | Cod sursa (job #2610673) | Cod sursa (job #562453) | Cod sursa (job #272895)
Cod sursa(job #272895)
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#define MAXN 1000
#define VAL 500
long n, co, t, i, j, aux, auxx, see, v[MAXN], SGR[MAXN];
int cmp(const void *w, const void *v) {
return *(int *)w - *(int *)v;
}
int main() {
freopen("bowling.in", "r", stdin);
freopen("bowling.out", "w", stdout);
v[0] = -1;
for (i = 1; i <= VAL; ++i) {
co = 0;
for (j = 0; j < i - 1; ++j) {
v[++co] = SGR[j] ^ SGR[i - j - 2];
}
for (j = 0; j < i; ++j) {
v[++co] = SGR[j] ^ SGR[i - j - 1];
}
qsort(v + 1, co, sizeof(v[0]), cmp);
v[co + 1] = v[co] + 10;
for (j = 0; j <= co; ++j)
if (v[j] + 1 < v[j + 1]) {
SGR[i] = v[j] + 1;
break;
}
}
SGR[0] = 0;
for (scanf("%ld", &t); t--; ) {
long nr = 0;
auxx = 0;
aux = 0;
for (scanf("%ld", &n); (n + 1); --n) {
see = 0;
if (n) {
scanf("%ld", &see);
}
if (see) {
++aux;
} else {
if (aux < 72) {
auxx ^= SGR[aux];
} else {
if (!((aux - 71) % 12)) {
nr = 12;
}
auxx ^= SGR[71 + ((aux - 71) % 12) + nr];
}
aux = 0;
}
}
if (auxx) {
printf("Nargy\n");
} else {
printf("Fumeanu\n");
}
}
}