威佐夫博弈——取石子游戏 POJ - 1067

这里写图片描述
题解:威佐夫博弈的板子题

#include<iostream>
#include<cstdio>
#include<map>
#include<algorithm>
#include<cmath>
#define LL long long
using namespace std;
int main()
{
    int a,b;
    double l = (sqrt((double)5)+1)/double(2); 
    while(~scanf("%d%d",&a,&b))
    {
        int c = abs(a-b);
        a = a>b?b:a;
        if(a==(int)(l*c)) printf("0\n");
        else printf("1\n");
    }
    return 0;
} 

猜你喜欢

转载自blog.csdn.net/qq_40240576/article/details/82667257
今日推荐