威佐夫博弈
洛谷p2252
直接给结论
小!=(大-小)黄金分割比例,先手赢
小==(大-小)黄金分割比例,后手赢
黄金分割比列:
\(\frac{\sqrt{5}+1}{2}\)
code
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
long double c = (1 + sqrtl(5)) / 2;
int main(){
cin.tie(nullptr)->sync_with_stdio(false);
int a, b;
cin >> a >> b;
if (a > b) swap(a, b);
if (int(c * (b - a)) == a) {
cout << "0\n";
} else {
cout << "1\n";
}
return 0;
}

浙公网安备 33010602011771号