Approach for problem GAMCOUNT

algorithm
maths
number-theory

#1

The problem link is: https://www.codechef.com/problems/GAMCOUNT
Approach:

As we know Henry gonna win every game in which possible number of all valid moves is odd.
So we calculate total number of valid moves of each of Xi(see NOTE) and sum them.
More generally Henry wins if the sum of all these moves is odd ,also problem can be simplified if considering total moves of each number Xi as either even or odd, then just look if there are odd number of odds in initial given Xi set and count these games in answer.

  • Is this approach is correct?
    NOTE: we can simply get valid number of moves with Xi by just knowing how many times we can subtract 2^V(Xi) so that resulting number be >=0.