HDU 1527 取石子游戏(威佐夫博弈)

  基础威佐夫博弈,判断奇异局势即可,判断方式为k为两数之差绝对值,(sqrt(5) + 1) / 2 * k若等于两数小者则为奇异局势,也就是必败态.

#include<stdio.h>
#include<iostream>
#include<cstring>
#include<cmath>
#include<queue>
using namespace std;
int main()
{
    int a,b;
    while(~scanf("%d%d",&a,&b))
    {
        int A = max(a,b);
        int B = min(a,b);
        int k = (A - B);
        A = int(k * (sqrt(5)+1)/2.0 );
        if(A == B)
        {
            puts("0");
        }
        else puts("1");
    }
    return 0;
}
原文地址:https://www.cnblogs.com/jifahu/p/5449092.html