Cod sursa(job #1214821)

Utilizator hrazvanHarsan Razvan hrazvan Data 31 iulie 2014 15:21:07
Problema Jocul NIM Scor 100
Compilator c Status done
Runda Arhiva educationala Marime 0.42 kb
#include <stdio.h>

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