2018 ICPC 南京区域赛 A - Adrien and Austin(对等博弈)

传送门


题目大意

给出 n n n个排列好位置不能变的石子,标号分别为 [ 1 , n ] [1,n] [1,n],两个人玩游戏,每次最多能取 k k k个连续的石子且不能不取,给定 n , k n,k n,k,输出第几个人获胜。

解题思路

第一个人取任何数量的石子,都会将集合分为不连续的两部分,这两部分可以看做尼姆博弈的特殊情况——对等博弈,这时第二个人只要能将这两个集合取成相等的两部分,第一个人必输。因此第一个人一定会想办法在第一次取后就能分成相等的两个集合,那么分析之后只有一种情况第一个人会输,也就是 n n n为偶数且 k = 1 k=1 k=1时,第一个人无论怎么取都必败。

此外还要注意 n = 0 n=0 n=0的特殊情况。


//
// Created by Happig on 2021/1/27.
//
#include <bits/stdc++.h>
#include <unordered_map>

using namespace std;
#define ENDL "\n"
#define lowbit(x) (x & (-x))
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const double eps = 1e-8;
const double pi = acos(-1.0);
const int inf = 0x3f3f3f3f;
const double dinf = 1e300;
const ll INF = 1e18;
const int Mod = 1e9 + 7;
const int maxn = 3e6 + 10;

int main() {
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n, k;
    cin >> n >> k;
    if (n == 0) cout << "Austin" << ENDL;
    else if (n % 2 == 0 && k == 1) cout << "Austin" << ENDL;
    else cout << "Adrien" << ENDL;
    return 0;
}
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值