PROBLEM LINKS
Author: Abdullah Al Mahmud
Tester: Gerald Agapov
Editorialist: Praveen Reddy Vaka
DIFFICULTY:
easy
PREREQUISITES:
Algorithmic Game Theory, Sprague Grundy Theorem
EXPLANATION
We need to find the grundy number of a single game and then we can find if the composite game is a winning position or not.
Detailed explanation for finding the grundy number using the minimum excluding number will be provided in a couple of hours. Refer tester's code to see how to compute the grundy number.
The single game happens to be a well studied game and goes by the name Euclid Game. There even exists a closed form solution for finding the grundy number for a given single game. Refer to http://www.sciencedirect.com/science/article/pii/S0012365X06003505. Setter's solution uses this.
SOLUTIONS
Setter's Solution: GAMEAAM.cpp
Tester's Solution: GAMEAAM.cpp