HEU 1015 Euclid's Game

 1/**************************************
 2Problem: HEU 1015 Euclid's Game
 3Time: 0.0010 s
 4Memory: 236 k 
 5Accepted Time: 2009-03-23 21:19:28
 6Tips: http://hi.baidu.com/justchenself/blog/item/8cbf62101912b707203f2e0d.html
 7**************************************/

 8#include <stdio.h>
 9void swap(int &a,int &b)
10{
11    int t=a; a=b; b=t;
12}

13int main()
14{
15    int a,b;
16    while(1)
17    {
18        scanf("%d%d",&a,&b);
19        if(a==0&&b==0)break;
20        int count=0,temp;
21        if(a<b)swap(a,b);
22        if(a%b==0){printf("Stan wins\n");continue;}
23        while(b)
24        {
25            if(a/b==1)
26            {
27                count++;
28                temp=b;
29                b=a%b;
30                a=temp;
31            }

32            else break;
33        }

34        if(count%2==0)printf("Stan wins\n");
35        else printf("Ollie wins\n");
36    }

37    return 0;
38}

39
posted @ 2009-04-02 11:58  主函数  阅读(190)  评论(0编辑  收藏  举报