HDU 1527 (Wythoff 博弈) 取石子游戏

对于Wythoff博弈中的两个数列,An和Bn有这样的关系:

An + n = Bn, An = floor(φ * n)

所以我们可以根据a b的差值来计算一个新的a出来看看这两个值是否相等。

想等的话,说明这个状态是个先手必败状态。

 1 #include <cstdio>
 2 #include <cmath>
 3 #include <algorithm>
 4 using namespace std;
 5 
 6 const double phi = (sqrt(5.0) + 1.0) / 2.0;
 7 
 8 int main()
 9 {
10     int a, b;
11     while(scanf("%d%d", &a, &b) == 2)
12     {
13         if(a > b) swap(a, b);
14         int t = phi * (b - a);
15         if(a == t) puts("0"); else puts("1");
16     }
17 }
代码君
原文地址:https://www.cnblogs.com/AOQNRMGYXLMV/p/4463084.html