Link to the question: uva 10368-Euclid's Game
Two numbers are given. Two people are playing a game. Each operation starts with stan and several small numbers can be taken from the maximum number, that is, a-kb, a is a relatively large number, B is a relatively small number, kb is the removed value, k must be an integer, and kb ≤. If the operation fails, the opponent wins.
Solution thinking: Simulate, until the maximum value of k is not 1, the current operator has the initiative, both can win. In special cases, stan wins when a = B.
# Include
# Include
# Include using namespace std; int main () {int a, B; while (scanf ("% d", & a, & B) = 2 & a + B) {int s = 0; if (! = B) {int x = max (a, B); int y = min (a, B); while (true) {if (x/y> 1) break; x = x % y; swap (x, y); s = 1-s ;}} printf ("% s wins \ n", s? "Ollie": "Stan");} return 0 ;}