威佐夫博弈扩展(HDU-6869 Slime and Stones)

威佐夫博弈扩展
第i个奇异局面为:
a [ i ] = ⌊ 1 − k − k 2 + 2 k + 5 2 i ⌋ a[i]=\lfloor\frac{1-k-\sqrt{k^2+2k+5}}{2}i\rfloor a[i]=21kk2+2k+5 i
b [ i ] = ⌊ 3 + k + k 2 + 2 k + 5 2 i ⌋ b[i]=\lfloor\frac{3+k+\sqrt{k^2+2k+5}}{2}i\rfloor b[i]=23+k+k2+2k+5 i
当k=0时,即为威佐夫博弈的结论。
做差即可验证:
b [ i ] − a [ i ] = ⌊ ( k + 1 ) i ⌋ b[i]-a[i]=\lfloor(k+1)i\rfloor b[i]a[i]=(k+1)i
i = ⌊ b [ i ] − a [ i ] ( k + 1 ) ⌋ i=\lfloor\frac{b[i]-a[i]}{(k+1)}\rfloor i=(k+1)b[i]a[i]

#include<cstdio>
#include<iostream>
#include<cstring>
#include <map>
#include <queue>
#include <set>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <list>
#include <bitset>
#include <array>
#include <cctype>
#include <time.h>

#pragma GCC optimize(2)

void read_f() { freopen("1.in", "r", stdin); freopen("1.out", "w", stdout); }
void fast_cin() { std::ios::sync_with_stdio(false); std::cin.tie(); }
void run_time() { std::cout << "ESC in : " << clock() * 1000.0 / CLOCKS_PER_SEC << "ms" << std::endl; }
template <typename T>
bool bacmp(const T & a, const T & b) { return a > b; }
template <typename T>
bool pecmp(const T & a, const T & b) { return a < b; }

#define ll long long
#define ull unsigned ll
#define _min(x, y) ((x)>(y)?(y):(x))
#define _max(x, y) ((x)>(y)?(x):(y))
#define max3(x, y, z) ( max( (x), max( (y), (z) ) ) )
#define min3(x, y, z) ( min( (x), min( (y), (z) ) ) )
#define pr(x, y) (make_pair((x), (y)))
#define pb(x) push_back(x);
using namespace std;

const int N = 1e5 + 5;
double f1(double k)
{
    return (sqrt(k*k+2*k+5.0) + 1 - k) / 2.0;
}
double f2(double k)
{
    return (sqrt(k*k+2*k+5) + 3 + k) / 2.0;
}
int main()
{
    int t; cin >> t;
    while(t--)
    {
        int a, b, k; scanf("%d%d%d", &a, &b, &k);
        if (a > b)
            swap(a, b);
        double k1 = f1(k);
        double k2 = f2(k);
        int d = (b - a) / (k + 1);
        if ((int)(d * k1) == a && (int)(d * k2) == b)
            puts("0");
        else puts("1");
    }
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值