Cod sursa(job #37657)

Utilizator ViksenVictor-Nicolae Savu Viksen Data 25 martie 2007 11:41:51
Problema Bowling Scor 0
Compilator cpp Status done
Runda preONI 2007, Runda 4, Clasa a 10-a Marime 0.73 kb
#include <stdio.h>

int main ()
{
    int t,n,i,x,xa,A[3];
    freopen ( "bowling.in" , "r" , stdin );
    freopen ( "bowling.out" , "w" , stdout );
    scanf ( "%d\n" , &t );
    for ( t ; t ; t-- ) {
        scanf ( "%d" , &n );
        A[0]=A[1]=A[2]=0;xa=0;
        for ( i=0 ; i<n ; i++ ) {
            scanf ( "%d" , &x );
            if (i==0) A[2]=x;
            if (i==1) A[2]=x|A[1];
            if (i>=2)
                if (x&&xa) A[2]=A[1]||A[0]; else
                if (x) A[2]=!A[1]; else A[i]=A[1];
            xa=x;
            A[0]=A[1];A[1]=A[2];A[2]=0;
        }
        if (A[1]) printf ( "Nargy\n" ); else printf ("Fumeanu\n") ;
    }
    fclose ( stdin );
    fclose ( stdout );
    return 0;
}