Hackerearth problem: Christmas-Gamecon

This problem was in the December easy challenge.

The solution is like this:
Basically you just take xor of all (nos%5). If it is 0 player B wins else player A wins.

Can someone explain me the idea behind this solution? there wasn’t editorial for this problem, so posting this question here.

Read this: http://en.wikipedia.org/wiki/Nim#The_subtraction_game_S.281.2C2.2C....2Ck.29

1 Like

thanks, that helped :slight_smile: