威佐夫博奕,有两堆物体,给出两堆物体的数量,每个人每次从两堆物体里任意一堆拿走任意多个物体,或者同时从两堆物体里拿走相同数量的物体,最后把所有物体拿完的人赢,即为威佐夫博奕。百度百科对威佐夫博奕的说明:http://baike.baidu.com/view/1952620.htm,感觉比较好懂。poj的1067就是威佐夫博奕,代码如下:
View Code
1 #include<iostream> 2 #include<cstdio> 3 #include<cmath> 4 using namespace std; 5 int main() 6 { 7 double t1=(1.0+sqrt(5.0))/2; 8 int a,b,k; 9 while(~scanf("%d%d",&a,&b)) 10 { 11 if(a>b) 12 { 13 a^=b; 14 b^=a; 15 a^=b; 16 } 17 k=b-a; 18 if(a==(int)(k*t1)) 19 printf("0\n"); 20 else 21 printf("1\n"); 22 } 23 return 0; 24 }