Meaning of the questions:
Give you two numbers n, m (assuming that n> m), and asked to let nk * m (k to ensure nk * m> = 0), who should cut out if the words of one who will win 0
answer:
When n% m == 0 upper hand wins
When n <2 * m, then only be removed by subtracting the result of evaluating step by step
When n> 2 * m when the upper hand wins. Assuming that this time we already know n% m and m is the number two or flip to win the upper hand to win, assuming the upper hand to win, then we can become n n% m + m
This time FLAC only two numbers becomes (n% m, m), and because this is a win-state, so to win the upper hand (if (n% m, m) is the flip win, then the upper hand can directly cause (n, m) becomes (n% m, m), and because this is a necessary and because input state flip turn away, so that the upper hand victory)
Code:
1 #include<stdio.h> 2 #include<string.h> 3 #include<iostream> 4 #include<algorithm> 5 #include<math.h> 6 #include<stack> 7 #include<math.h> 8 using namespace std; 9 typedef long long ll; 10 const int maxn=1000000; 11 int main() 12 { 13 int n,m; 14 while(~scanf("%d%d", & n-, & m)) 15 { 16 IF (n-== 0 && m == 0 ) BREAK ; . 17 IF (n-< m) the swap (n-, m); 18 is int In Flag = 0 ; . 19 the while ( . 1 ) 20 is { 21 is IF (n-/ m> = 2 || == n- m) 22 is BREAK ; 23 is N- = m; 24 the swap (n-, m); // because all the remaining n / m <2, so after each n- = m, n on the m is smaller than 25 In Flag = ^ . 1; 26 } 27 if(!flag) printf("Stan wins\n"); 28 else printf("Ollie wins\n"); 29 } 30 return 0; 31 }