且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

hdu 1527

更新时间:2022-08-13 08:45:08

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1527
hint:威佐夫博弈
基本类似于模板

#include <iostream>
#include <cmath>
#include <cstdio>       
using namespace std;
const double q = (1 + sqrt(5.0)) / 2.0;   // 黄金分割数
int Wythoff(int a, int b)
{
    if (a > b)
       swap(a, b);
    int k = b - a;
    if (a == (int)(k * q))
       return 0;               // 奇异局面, 先手必败
    return 1;
}
int main ()
{
    int a, b;
    while (scanf("%d%d", &a, &b) != EOF)
    {
       printf("%d\n", Wythoff(a, b));
    }
}