您的位置:首页 > 其它

hdu 1527

2015-06-18 22:27 423 查看
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1527

hint:威佐夫博弈

基本类似于模板

[code]#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));
    }
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: