Cod sursa(job #1675402)
| Utilizator | Data | 5 aprilie 2016 12:09:27 | |
|---|---|---|---|
| Problema | Jocul NIM | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.53 kb |
#include <fstream>
using namespace std;
FILE * fin = fopen("nim.in", "r");
FILE * fout = fopen("nim.out", "w");
int main()
{
long long int i, j, t, n, x, suma;
fscanf(fin, "%lld", &t);
for (i=1; i<=t; i++)
{
fscanf(fin, "%lld", &n);
suma=0;
for (j=1; j<=n; j++)
{
fscanf(fin, "%lld", &x);
suma=suma^x;
}
if (suma) fprintf(fout, "DA\n");
else fprintf(fout, "NU\n");
}
fclose(fin);
fclose(fout);
return 0;
}
