Cod sursa(job #955295)

Utilizator toranagahVlad Badelita toranagah Data 31 mai 2013 14:03:14
Problema Bowling Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 1.14 kb
#include <algorithm>
#include <fstream>
#include <iostream>
using namespace std;

const int MAX_N = 50100;

ifstream fin("bowling.in");
ofstream fout("bowling.out");

int T, N;
vector<int> v;

int nimbers[84] = {1, 2, 3, 1, 4, 3, 2, 1, 4, 2, 6, 4, 
                   1, 2, 7, 1, 4, 3, 2, 1, 4, 6, 7, 4, 
                   1, 2, 8, 5, 4, 7, 2, 1, 8, 6, 7, 4, 
                   1, 2, 3, 1, 4, 7, 2, 1, 8, 2, 7, 4, 
                   1, 2, 8, 1, 4, 7, 2, 1, 4, 2, 7, 4, 
                   1, 2, 8, 1, 4, 7, 2, 1, 8, 6, 7, 4,
                   1, 2, 8, 1, 4, 7, 2, 1, 8, 2, 7, 4}; 


int main() {
  fin >> T;
  for (int t = 0; t < T; ++t) {
    fin >> N;
    int x = 0;
    for (int i = 0, p; i < N; ++i) {
      fin >> p;
      x += p;
      if (p == 0) {
        if (x > 0) {
          v.push_back(x);
        }
        x = 0;
      }
    }
    if (x > 0) v.push_back(x);

    int xor_sum = 0;
    for (auto i : v) {
      int pos = i - 1;
      if (pos >= 84) {
        pos %= 12;
        pos += 72;
      }
      xor_sum ^= nimbers[pos];
    }

    if (xor_sum == 0) {
      fout << "Fumeanu\n";
    } else {
      fout << "Nargy\n";
    }
    v.clear();
  }
}