HDU-1527 取石子游戏(Hdu-1527 stone game)

取石子游戏

威佐夫博弈

板子加规律题,就很没办法

他们的差值与最小的那个值有黄金分割比例,最小的那个值比差值大

#include <iostream>
#include <cmath>
using namespace std;
typedef long long ll;

int main()
{
    ll n, m;
    while(cin >> n >> m)
    {
        if(n > m) swap(n, m);
        double w = (sqrt(5.0) + 1.0) / 2.0;
        ll x = (m - n) * w;
        if(x == n) cout << 0 << endl;
        else cout << 1 << endl;
    }
    return 0;
}
————————

Stone game

Wythoff game

If you add regular questions to the board, you can’t help it

Their difference has a golden ratio to the smallest value, and the smallest value is greater than the difference

#include <iostream>
#include <cmath>
using namespace std;
typedef long long ll;

int main()
{
    ll n, m;
    while(cin >> n >> m)
    {
        if(n > m) swap(n, m);
        double w = (sqrt(5.0) + 1.0) / 2.0;
        ll x = (m - n) * w;
        if(x == n) cout << 0 << endl;
        else cout << 1 << endl;
    }
    return 0;
}