Cod sursa(job #37835)

Utilizator andrei_h5n1Haidau Andrei andrei_h5n1 Data 25 martie 2007 12:46:49
Problema Bowling Scor 0
Compilator cpp Status done
Runda preONI 2007, Runda 4, Clasa a 10-a Marime 0.87 kb
#include <fstream.h>

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

long  t, n, nr, k, i, j, x, y, aux1;

int main()
{
	fin>>t;
	for(i=1; i<=t; i++)
	{
		fin>>n;
		aux1=0;
		x=0;
		y=0;
		for(j=1; j<=n; j++)
		{
			fin>>nr;
			k=0;
			if(nr)
			{
			while(nr && j<=n)
			{
				k++;
				j++;
				if(j>n)
					break;
				fin>>nr;
			}
			if(k==1)
				aux1++;
			else
			{
				if(k%4==1)
				{
					aux1++;
				}
				else if(k%4==2)
				{
					if(x==1)
					{
						x=0;
						y=0;
					}
					else
						x=1;
				}
				else if(k%4==3)
				{
					aux1++;
					if(x==1)
					{
						x=0;
						y=0;
					}
					else
						x=1;
				}
			}
			}
		}
		if(aux1%2==1)
		{
			if(x==1)
			{
				x=0;
				y=0;
			}
			else
				x=1;
		}
		if(x==y)
			fout<<"Fumeanu\n";
		else
			fout<<"Nargy\n";
	}
	return 0;
}