Cod sursa(job #1895535)

Utilizator bleo16783FMI Bleotiu Cristian bleo16783 Data 28 februarie 2017 00:13:14
Problema Jocul NIM Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.75 kb
#include <fstream>
#include<iostream>
using namespace std;
#define DIM 10000
int a,s,n,t,poz;
char buff[DIM];
ifstream f("nim.in");
void R(int &x)
{
    x=0;
    while(buff[poz]<'0'||buff[poz]>'9')
        if(++poz==DIM)
    {
        poz=0;
        f.read(buff,DIM);
    }
    while(buff[poz]>='0'&&buff[poz]<='9')
    {
        x=x*10+buff[poz]-'0';
        if(++poz==DIM)
        {
            poz=0;
            f.read(buff,DIM);
        }
    }
}
int main()
{
    R(t);
    ofstream g("nim.out");
    while(t--)
    {
        R(n);
        s=0;
        while(n--)
        {
            R(a);
            s^=a;
        }
        if(s)
            g<<"DA\n";
        else
            g<<"NU\n";
    }
    return 0;
}