首页 > 编程语言 >B 小沙の博弈【2023牛客寒假算法基础集训营5】

B 小沙の博弈【2023牛客寒假算法基础集训营5】

时间:2023-02-01 22:33:06浏览次数:52  
标签:include const int 石子 牛客 小沙 集训营 字典

B 小沙の博弈

原题链接

题意

字典序贪心

思路

考虑需要使自己的字典序比对方小,那么每次都尽可能的少选,由于每次必须选择一个,那么双方都
一直选择一个直至石子被取完
当石子数目为偶数时,双方的取石子的次数相同,得到的字典序也相同,所以平手
当石子数目为奇数时,先手会比后手多取一次,所以得到的字典序大于后手,所以后手获胜。

代码

点击查看代码
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
using namespace std;

#define X first
#define Y second

typedef pair<int,int> pii;
typedef long long LL;
const char nl = '\n';
const int N = 1e6+10;
const int M = 1e6+10;
int n,m;

void solve(){
	cin >> n;
	if(n%2==0)cout << "win-win!";
	else cout << "Yaya-win!";
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);

	solve();
}

标签:include,const,int,石子,牛客,小沙,集训营,字典
From: https://www.cnblogs.com/J-12045/p/17084339.html

相关文章