poj 1067取石子(威佐夫博奕)

/*

*威佐夫博奕(Wythoff Game): 有两堆各若干个物品,两个人轮流从某一堆或同时从两

*堆中取同样多的物品,规定每次至少取一个,多者不限,最后取光者得胜.

*(ak,bk)(ak bk ,k=0,1,2,...,n)表示两堆物品的数量,则

*奇异局面(先手必败, P-Position) ak =[k(1+5)/2], bk= ak + k (k=0,1,2,...,n 方括

*号表示取整函数)

*/

 

 1 #include<iostream>
 2 #include<cmath>
 3 using namespace std;
 4 
 5 int main()
 6 {
 7     double arph=(sqrt(5.0)+1.0)/2.0;//黄金分割数
 8     int a,b;
 9     while (cin>>a>>b)
10     {
11         if (b<a) swap(a,b);
12         int n=b-a;
13         int c=floor(n*arph);
14         if (c==a) cout<<0<<endl;
15         else cout<<1<<endl;
16     }
17     return 0;
18 }
原文地址:https://www.cnblogs.com/redlight/p/2445314.html