Cod sursa(job #72471)

Utilizator info_arrandrei gigea info_arr Data 13 iulie 2007 22:31:48
Problema Bowling Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 1.23 kb
#include <cstdio>

using namespace std;

#define FIN "bowling.in"
#define FOUT "bowling.out"
#define MAX_N 50005

const int A[84] = {
 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};

const int per[12]= {4, 1, 2, 8, 1, 4, 7, 2, 1, 8, 2, 7}; 

int a[MAX_N];
int N,T,i,j;
int p,Rez,k;
 
int main()
{
    freopen(FIN,"r",stdin);
    freopen(FOUT,"w",stdout);
    scanf("%d",&T);
    
    for (j=1; j<=T; j++)
     {
       scanf("%d",&N);
       for (i=1; i<=N; i++) scanf("%d",a+i);
       Rez=0;
       for (i=1; i<=N; i++)
        {
          p=0;       
          while (a[i]==1)
           {
             p++; i++;
             if (a[i]!=1) { i--; break; }
           }
          while (a[i]==0 && i<=N)
           {
             i++;
             if (a[i]!=0) { i--; break; }
           }
          if (p<80) k=A[p]; 
           else k=per[p%12]; 
          Rez^=k; 
        }           
       if (Rez&1) printf("NARGY\n");
        else printf("FUMEANU\n");  
     }
    return 0;
}