Skip to content

Instantly share code, notes, and snippets.

@jianminchen
Created December 28, 2016 18:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jianminchen/779cc29382e915025049927e060226c0 to your computer and use it in GitHub Desktop.
Save jianminchen/779cc29382e915025049927e060226c0 to your computer and use it in GitHub Desktop.
week code 27 - zero move nim game - study code - Java
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int g = in.nextInt();
for(int a0 = 0; a0 < g; a0++){
int n = in.nextInt();
int[] p = new int[n];
int sum = 0;
for(int p_i=0; p_i < n; p_i++){
p[p_i] = in.nextInt();
if (p[p_i] % 2 == 0) p[p_i]--;
else p[p_i]++;
sum = sum ^ p[p_i];
}
if (sum == 0) System.out.println("L");
else System.out.println("W");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment