当前位置:网站首页>Game theory acwing 894 Split Nim game
Game theory acwing 894 Split Nim game
2022-07-05 06:24:00 【T_ Y_ F666】
Game theory AcWing 894. Split -Nim game
Original link
Algorithm tags
Math knowledge Game theory SG function
Ideas
Code
#include<bits/stdc++.h>
#define int long long
#define abs fabs
#define rep(i, a, b) for(int i=a;i<b;++i)
#define Rep(i, a, b) for(int i=a;i>=b;--i)
using namespace std;
const int N = 105, M = 10005;
int f[M];
int n;
inline int read(){
int s=0,w=1;
char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
return s*w;
}
void put(int x) {
if(x<0) putchar('-'),x=-x;
if(x>=10) put(x/10);
putchar(x%10^48);
}
int sg(int x){
if(f[x]!=-1){
return f[x];
}else{
unordered_set<int> S;
// Quantity requirements for the first pile
rep(i, 0, x){
// Quantity requirements of the second pile
rep(j, 0, i+1){
S.insert(sg(i)^sg(j));
}
}
// mex function
for(int i=0;;++i){
if(!S.count(i)){
return f[x]=i;
}
}
}
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
memset(f, -1, sizeof f);
n=read();
int ans=0;
while(n--){
int x=read();
ans^=sg(x);
}
if(ans){
puts("Yes");
}else{
puts("No");
}
}
Originality is not easy.
Reprint please indicate the source
If it helps you Don't forget to praise and support
边栏推荐
- 3. Oracle control file management
- P2575 master fight
- TCP's understanding of three handshakes and four waves
- Leetcode recursion
- 栈 AcWing 3302. 表达式求值
- Leetcode-1200: minimum absolute difference
- Ffmpeg build download (including old version)
- Regulations for network security events of vocational group in 2022 Guizhou Vocational College skill competition
- Sorting out the latest Android interview points in 2022 to help you easily win the offer - attached is the summary of Android intermediate and advanced interview questions in 2022
- 20220213-CTF MISC-a_ good_ Idea (use of stegsolve tool) -2017_ Dating_ in_ Singapore
猜你喜欢
安装OpenCV--conda建立虚拟环境并在jupyter中添加此环境的kernel
博弈论 AcWing 891. Nim游戏
Sqlmap tutorial (II) practical skills I
5. Oracle TABLESPACE
Redis publish subscribe command line implementation
MySQL advanced part 2: SQL optimization
2021apmcm post game Summary - edge detection
4. Oracle redo log file management
Navicat连接Oracle数据库报错ORA-28547或ORA-03135
MySQL advanced part 1: index
随机推荐
Leetcode-9: palindromes
高斯消元 AcWing 884. 高斯消元解异或線性方程組
Currently clicked button and current mouse coordinates in QT judgment interface
5.Oracle-錶空間
P3265 [jloi2015] equipment purchase
阿里新成员「瓴羊」正式亮相,由阿里副总裁朋新宇带队,集结多个核心部门技术团队
Record the process of configuring nccl and horovod in these two days (original)
Leetcode-6111: spiral matrix IV
Simple selection sort of selection sort
如何正确在CSDN问答进行提问
What is socket? Basic introduction to socket
1.13 - RISC/CISC
Alibaba's new member "Lingyang" officially appeared, led by Peng Xinyu, Alibaba's vice president, and assembled a number of core department technical teams
[2020]GRAF: Generative Radiance Fields for 3D-Aware Image Synthesis
Daily question 1189 Maximum number of "balloons"
C job interview - casting and comparing - C job interview - casting and comparing
4.Oracle-重做日志文件管理
【LeetCode】Day94-重塑矩阵
RecyclerView的应用
Find the combination number acwing 887 Find combination number III