Cod sursa(job #2393986)

Utilizator Radu_FilipescuFilipescu Radu Radu_Filipescu Data 1 aprilie 2019 11:30:09
Problema Jocul NIM Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.46 kb
#include <fstream>

using namespace std;

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

int Q;

int main()
{
    fin >> Q;

    int N, nr, ans;

    for( int i = 1; i <= Q; ++i )
    {
      fin >> N;

      ans = 0;

      for( int j = 1; j <= N; ++j )
      {
        fin >> nr;

        ans = ans ^ nr;
      }

      ( ans ) ? fout << "DA\n" : fout << "NU\n";
    }

    fin.close();
    fout.close();

    return 0;
}