Pagini recente » Cod sursa (job #2746896) | Cod sursa (job #2191672) | Cod sursa (job #378158) | Cod sursa (job #3162493) | Cod sursa (job #885172)
Cod sursa(job #885172)
#include <cstring>
#include <fstream>
#include <algorithm>
#include <vector>
using namespace std;
int T, N;
int SP[1002];
bool ok[1002];
vector<int> V;
int main()
{
ifstream fin("bowling.in");
ofstream fout("bowling.out");
// ciclic din 12 in 12 (de la un moment dat)
for (int i = 1; i <= 1000; ++i)
{
memset(ok, 0, sizeof(ok));
for (int j = 0; j <= i - 1; ++j)
ok[SP[j] ^ SP[i - j - 1]] = true;
for (int j = 0; j <= i - 2; ++j)
ok[SP[j] ^ SP[i - j - 2]] = true;
for (int j = 0; ok[j]; ++j, ++SP[i]);
}
fin >> T;
for (int test = 1; test <= T; ++test)
{
V.clear();
fin >> N;
int now = 0, result = 0;
for (int i = 1, aux; i <= N; ++i)
{
fin >> aux;
if (aux == 0)
{
if (now != 0)
{
if (now >= 1000) now = 601 + now % 12;
result ^= SP[now];
}
now = 0;
}
if (aux == 1) ++now;
}
if (now != 0)
{
result ^= SP[now];
if (now >= 1000) now = 601 + now % 12;
}
if (result == 0) fout << "Fumenau\n";
else fout << "Nargy\n";
}
fin.close();
fout.close();
}