HEU 1015 Euclid's Game
1
/**************************************
2
Problem: HEU 1015 Euclid's Game
3
Time: 0.0010 s
4
Memory: 236 k
5
Accepted Time: 2009-03-23 21:19:28
6
Tips: http://hi.baidu.com/justchenself/blog/item/8cbf62101912b707203f2e0d.html
7
**************************************/
8
#include <stdio.h>
9
void swap(int &a,int &b)
10
{
11
int t=a; a=b; b=t;
12
}
13
int 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
/**************************************2
Problem: HEU 1015 Euclid's Game3
Time: 0.0010 s4
Memory: 236 k 5
Accepted Time: 2009-03-23 21:19:286
Tips: http://hi.baidu.com/justchenself/blog/item/8cbf62101912b707203f2e0d.html7
**************************************/8
#include <stdio.h>9
void swap(int &a,int &b)10
{11
int t=a; a=b; b=t;12
}13
int 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




浙公网安备 33010602011771号