Created
December 28, 2016 18:45
-
-
Save jianminchen/779cc29382e915025049927e060226c0 to your computer and use it in GitHub Desktop.
week code 27 - zero move nim game - study code - Java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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