Cod sursa(job #2601025)

Utilizator sulzandreiandrei sulzandrei Data 13 aprilie 2020 16:32:54
Problema Bowling Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 1.32 kb
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <unordered_set>
#include <vector>
#include <fstream>
using namespace std;

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



int g[]={0,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};

int sg(int n){
    if(n<=71){
        return g[n];
    }
    int rest = n%12;
    switch(rest){
        case 0: return 4;
        case 1: return 1;
        case 2: return 2;
        case 3: return 8;
        case 4: return 1;
        case 5: return 4;
        case 6: return 7;
        case 7: return 2;
        case 8: return 1;
        case 9: return 8;
        case 10: return 2;
        case 11: return 7;
    }
}
int main(){

    int n,t,el;
    in>>t;
    while(t--){
        in>>n;
        int ps=0;
        int xors=0;
        for(int i = 0 ; i< n ; i++){
            in>>el;
            if(el==1){
                ps++;
            }
            if(el==0 && ps>0){
                xors^=sg(ps);
                ps=0;
            }
        }
        if(ps>0){
            xors ^=g[ps];
        }
        if(xors>0){
            out<<"Nargy\n";
        }else {
            out<<"Fumeanu\n";
        }

    }

    return 0;
}