atcoder#CF16EXHIBITIONFINALC. Cheating Nim
Cheating Nim
Score : points
Problem Statement
A cheetah and a cheater are going to play the game of Nim. In this game they use piles of stones. Initially the -th pile contains stones. The players take turns alternately, and the cheetah plays first. In each turn, the player chooses one of the piles, and takes one or more stones from the pile. The player who can't make a move loses.
However, before the game starts, the cheater wants to cheat a bit to make sure that he can win regardless of the moves by the cheetah. From each pile, the cheater takes zero or one stone and eats it before the game. In case there are multiple ways to guarantee his winning, he wants to minimize the number of stones he eats.
Compute the number of stones the cheater will eat.
In case there is no way for the cheater to win the game even with the cheating, print -1
instead.
Constraints
Input
The input is given from Standard Input in the following format:
:
Output
Print the answer.
3
2
3
4
3
The only way for the cheater to win the game is to take stones from all piles and eat them.
3
100
100
100
-1