Cod sursa(job #781654)

Utilizator Mihai22eMihai Ionut Enache Mihai22e Data 24 august 2012 19:52:54
Problema Jocul NIM Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.43 kb
#include<stdio.h>

using namespace std;

int t, n, x, i;
long long int s;

int main()
{
	FILE *f = fopen("nim.in", "r");
	
	FILE *g = fopen("nim.out", "w");
	
	fscanf(f, "%d", &t);
	
	for( ; t; --t)
	{
		fscanf(f, "%d", &n), s = 0;
		for(i = 0; i < n; ++i)
			fscanf(f, "%d", &x), s ^= x;
		
		if(s)
			fprintf(g, "DA\n");
		else
			fprintf(g, "NU\n");
	}
	
	fclose(f);
	
	fclose(g);
	
	return 0;
}