Plus
Pin


Problem description Progress
ID 33298. chocolate bar
Темы: Grundy function   

Two people play this game: in front of them is an NxM chocolate bar. During a turn, you can break the existing piece of chocolate along one of the sides into 2 "non-empty" ones.
 
However, you can't break pieces no larger than 1k (pieces can be rotated; we consider one piece "at most" another if it is equal to it or part of it). Thus, it is impossible to break pieces of size 11, 12, , 1k, but other pieces can be broken.
 
The one who cannot make a move loses. Determine who will be the winner in the game if the initial dimensions of the chocolate are known.
 
Input
Enter integers 0 < N, M, K <= 100.
 
Output
Output 1 or 2 - the number of the player who will win if the game is correct.

Enter Output
1 1 1 2
2 2 1 1