Cod sursa(job #138219)

Utilizator floringh06Florin Ghesu floringh06 Data 17 februarie 2008 23:05:18
Problema Bowling Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 1.41 kb
#include <cstdio>
#include <cstring>

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);
       memset (a, 0, sizeof (a));
       for (i=1; i<=N; i++) scanf("%d",a+i);
       Rez=0;
       for (i=1; i<=N; i++)
        {
          p=0;
          if (a[i]==0)
           while (a[i]==0 && i<=N) i++;
          while (a[i]==1)
           {
                p++; i++;
           }
          if (p<72) k=A[p]; else k=per[p%12];
          Rez^=k;         
        }       
  //    printf("%d\n",Rez)     ;
     /* if (Rez<72) 
         if (A[Rez]<=1) printf("Fumeanu\n");
          else printf("Nargy\n");
      if (Rez>=72)
         if (per[Rez%12]<=1) printf("Fumeanu\n");
          else printf("Nargy\n");   */
         if (!Rez)
            printf ("Fumeanu\n"); else printf ("Nargy\n");
     }
    return 0;
}