Redirecting to

First Move In A Nim Game

Two players Alice and Bob are playing NIM Game with each other. Both are playing optimally.Alice starts the game. The task is to find the number of ways of playing 1st move for Alice to ensure a winning strategy for him if possible, otherwise print -1.
Input Format
The first line contains one integer n.
The second line contains n space separated integers a[1],a[2]...a[n].
Output Format
Print the number of possible first move for Alice to win. If Alice can't win, Print -1.
Question Video
1<= n <= 10^5
1<= A[i] <= 10^8
Sample Input
24 6 10 56 9 1 24
Sample Output

  • Asked in Companies
  • Related Topics

Video Solution

Code Solution

Id Name