Make XOR zero
Read problems statements in Mandarin Chinese , Russian and Vietnamese
Olya has written N binary integers (i.e. either zero or one) on a blackboard. She recently learned about XOR operation. Now she wants to erase exactly one integer in the array so that the XOR of the remaining N - 1 numbers is zero. Please help her to calculate the number of ways of doing so.
The first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows.
The first line of each test case contains a single integer N denoting the number of numbers that Olya has written on a blackboard.
The second line contains N space-separated integers A1, A2, ..., AN denoting the numbers she had written.
OutputFor each test case, output a single line containing the number of ways to erase exactly one integer so that the XOR of the remaining integers is zero. The ways where you erase the same integer but on different places in the given sequence are considered different.
- 1 ≤ T ≤ 20
- 2 ≤ N ≤ 105
- 0 ≤ Ai ≤ 1
Input: 2 5 1 0 0 0 0 5 1 1 1 1 1 Output: 1 5
Example case 1. If you erase the first number on the blackboard, then the XOR of the rest of numbers will be equal to zero.
Example case 2. You can erase any of the given 5 numbers, it will make the XOR of the rest equal to zero.
|Tags||ad-hoc, counting, snck151b, xcwgf666|
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, SCM chicken, CLOJ, FS|
Fetching successful submissions