如果xy中较小的数等于xy的差值乘黄金分割比的话说先手必败
否则先手必胜
代码如下:
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
using namespace std;
int a,b;
signed main(void){
double k=(sqrt(5.0)+1.0)/2.0;//黄金分割比
while(scanf("%d%d",&a,&b)!=EOF){
if(min(a,b)==(int)(abs(a-b)*k))
cout<<0<<endl;
else
cout<<1<<endl;
}
return 0;
}
by >o< neighthorn

本文介绍了一种基于黄金分割比的简单博弈策略。该策略应用于两个整数a和b,通过比较它们之间的关系来判断先手玩家是否必胜。具体来说,如果较小的数等于两数之差的黄金分割比倍数,则先手必败;反之则必胜。文章提供了实现这一策略的C++代码。
1万+

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



