Cod sursa(job #2302137)

Utilizator borscalinCalin-Stefan Georgescu borscalin Data 13 decembrie 2018 20:49:25
Problema Jocul NIM Scor 100
Compilator c-64 Status done
Runda Arhiva educationala Marime 0.57 kb
#include <stdio.h>

int main() {
    int t, n, i, j;

    FILE *fin = fopen ( "nim.in", "r" );
    fscanf ( fin, "%d", &t );
    FILE *fout = fopen ( "nim.out", "w" );
    for ( j = 0; j < t; ++j ) {
        fscanf ( fin, "%d", &n );
        int x;
        int sumxor = 0;
        for ( i = 0; i < n; ++i ) {
            fscanf ( fin, "%d", &x );
            sumxor ^= x;
        }
        if ( !sumxor )
            fprintf ( fout, "NU\n" );
        else
            fprintf ( fout, "DA\n" );
    }

    fclose ( fin );
    fclose ( fout );

    return 0;
}