All Tracks Math Problem

The Nim Game Ritual
Tag(s):

Easy-Medium

Problem
Editorial
Analytics

Watson and Sherlock are playing the game of Nim.

The game of Nim is played as follows:

1) n heaps are given containing varying number of stones.
2) The two players take alternate turns in removing one or more number of stones from a heap.
3) The last player to remove the last set of stones win.

Given the configuration of heaps at any instant of game help Watson in counting the different moves he can make in one step , so that he finally wins the game.

Input: First line contain number of testcases t.

Each testcase consists of two lines:
The first line contains the number of heaps n.
The second line contains n separate integers , each denoting no. of stones in the ith pile.

Output: Print the no. of different moves that watson can make for each testcase.

constraints:

  • $$1 \le t \le 100$$
  • $$1 \le n \le 1000000$$
  • $$1 \le number_of _stones_in_a_heap \le 1000000$$

SAMPLE INPUT
1
3
13 12 8
SAMPLE OUTPUT
3
Time Limit: 1.0 sec(s) for each input file.
Memory Limit: 256 MB
Source Limit: 1024 KB
Marking Scheme: Marks are awarded when all the testcases pass.
Allowed Languages: C, C++, C++14, Clojure, C#, D, Erlang, F#, Go, Groovy, Haskell, Java, Java 8, JavaScript(Rhino), JavaScript(Node.js), Julia, Kotlin, Lisp, Lisp (SBCL), Lua, Objective-C, OCaml, Octave, Pascal, Perl, PHP, Python, Python 3, R(RScript), Racket, Ruby, Rust, Scala, Swift, Visual Basic

CODE EDITOR

Initializing Code Editor...
Your Rating:

Contributor

This Problem was Asked in

School of Engineering, CUSAT

Challenge Name

221B Baker Street: Code for Watson

OTHER PROBLEMS OF THIS CHALLENGE
Notifications
View All Notifications