NBUT 1582 比赛吃鸡腿 wythoff博弈

本文通过一段简洁的C++代码示例介绍了Wythoff博弈的基本判定方法,利用数学原理判断博弈状态,为读者提供了一个清晰的理解Wythoff博弈胜负判定的途径。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

NBUT 1582 比赛吃鸡腿 wythoff博弈
关于博弈的可以看这里
这是裸的wythoff,没啥意思,不过当时知道结论,就是想了好久不知道怎么判定,在这里记录一下。

代码:

/*************************************************************************
    > File Name: f.cpp
    > Author: gwq
    > Mail: gwq5210@qq.com 
    > Created Time: 2015年05月01日 星期五 13时42分26秒
 ************************************************************************/

#include <cmath>
#include <ctime>
#include <cctype>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>

#define INF (INT_MAX / 10)
#define clr(arr, val) memset(arr, val, sizeof(arr))
#define pb push_back
#define sz(a) ((int)(a).size())

using namespace std;
typedef set<int> si;
typedef vector<int> vi;
typedef map<int, int> mii;
typedef long long ll;

const double esp = 1e-5;

ll n, m;

int main(int argc, char *argv[])
{
    while (scanf("%lld%lld", &n, &m) != EOF) {
        ll a = min(n, m);
        ll b = max(n, m);
        ll k = b - a;
        ll t = (1.0 + sqrt(5.0)) / 2.0 * k;
        if (a + t == b) {
            printf("0\n");
        } else {
            printf("1\n");
        }
    }

    return 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值