Posted on 2008-03-16 17:03
superman 阅读(679)
评论(1) 编辑 收藏 引用 所属分类:
ZOJ
1 /* Accepted 1913 C++ 00:00.00 836K */
2 #include <string>
3 #include <iostream>
4
5 using namespace std;
6
7 void swap(int & a, int & b)
8 {
9 a = a ^ b;
10 b = a ^ b;
11 a = a ^ b;
12 }
13
14 int main()
15 {
16 int a, b;
17 string player[2] = {"Stan", "Ollie"};
18 while(cin >> a >> b)
19 {
20 if(a == 0 && b == 0)
21 break;
22
23 int curPlayer = 0;
24 while(1)
25 {
26 if(a < b)
27 swap(a, b);
28
29 if(a - b >= b)
30 break;
31
32 a = a % b;
33 if(a == 0 || b == 0)
34 break;
35
36 curPlayer = (++curPlayer) % 2;
37 }
38 cout << player[curPlayer] << ' ' << "wins" << endl;
39 }
40
41 return 0;
42 }
43