这里说的很详细:http://blog.youkuaiyun.com/y990041769/article/details/21694007
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
#include<string>
#include<cstring>
#include<cstdio>
#include<cmath>
typedef long long LL;
using namespace std;
LL a,b,c; //c为差值
int main()
{
// freopen("E:\\ACM\\test.txt","r",stdin);
double d=(sqrt(5)+1)/2.0; //威佐夫博弈1.618
// printf("%.10f\n",d);
while(cin>>a>>b)
{
if(a<b) swap(a,b);
c=(a-b)*d;
if(c==min(a,b)) puts("0");
else puts("1");
}
return 0;
}
威佐夫博弈算法实现
本文介绍了一种基于威佐夫博弈理论的算法实现。通过使用C++编程语言,该程序能够有效地判断两个数在威佐夫博弈规则下的胜负情况。核心算法利用了黄金分割比例来确定游戏状态。
1万+

被折叠的 条评论
为什么被折叠?



