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

时间:2022-04-17 21:03:40

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

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

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

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

 #include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std; const double phi = (sqrt(5.0) + 1.0) / 2.0; int main()
{
int a, b;
while(scanf("%d%d", &a, &b) == )
{
if(a > b) swap(a, b);
int t = phi * (b - a);
if(a == t) puts(""); else puts("");
}
}

代码君