Logan and his XOR debacle
All submissions for this problem are available.
The enmity between Logan and Donald Pierce never ceases to exist.
However, once Logan and Donald came face to face. Donald got agitated and asked Logan to prove his true mettle by solving a puzzle.
Logan is provided an array Arr of N integers. He can select only a single integer from the array and can perform certain special operations on it any number of time.
An operation can be one of the following type :
- Decrement the integer by 1 provided that it is greater than 0
- Increment the integer by 1
Donald asks Logan to tell the least number of operations required to obtain the smallest possible XOR sum of all the integers.
Since Logan is currently in hurry to meet Charles and Canibal, he asks you guys to solve this problem. Help him!!
First line contains an integer T denoting number of test cases.
First line of each test case contains an integer N.
Second line of each test case contains N space separated integers
For each test case, print an integer denoting the minimum number of required operations on a separate line.
- 1 ≤ T ≤ 10
- 1 ≤ N ≤ 105
- 0 ≤ Arr[i] ≤ 4294967296
1 1 1 1
Since the XOR sum of all numbers is 0 and can't be reduced further, the answer is 0.
|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