当前位置:网站首页>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
边栏推荐
- RecyclerView的应用
- 1.15 - input and output system
- Traditional databases are gradually "difficult to adapt", and cloud native databases stand out
- P2575 master fight
- Operator priority, one catch, no doubt
- [2021]IBRNet: Learning Multi-View Image-Based Rendering Qianqian
- 4. 对象映射 - Mapping.Mapster
- Sum of three terms (construction)
- MySQL advanced part 1: View
- Presentation of attribute value of an item
猜你喜欢
Alibaba's new member "Lingyang" officially appeared, led by Peng Xinyu, Alibaba's vice president, and assembled a number of core department technical teams
Liunx starts redis
阿里新成员「瓴羊」正式亮相,由阿里副总裁朋新宇带队,集结多个核心部门技术团队
博弈论 AcWing 891. Nim游戏
Real time clock (RTC)
SPI details
求组合数 AcWing 888. 求组合数 IV
求组合数 AcWing 889. 满足条件的01序列
4. 对象映射 - Mapping.Mapster
Operator priority, one catch, no doubt
随机推荐
Redis-01.初识Redis
Quickly use Amazon memorydb and build your own redis memory database
Network security skills competition in Secondary Vocational Schools -- a tutorial article on middleware penetration testing in Guangxi regional competition
How to make water ripple effect? This wave of water ripple effect pulls full of retro feeling
Leetcode divide and conquer / dichotomy
Groupbykey() and reducebykey() and combinebykey() in spark
One question per day 1020 Number of enclaves
C job interview - casting and comparing - C job interview - casting and comparing
Bash exercise 17 writing scripts to install the server side of FRP reverse proxy software
背包问题 AcWing 9. 分组背包问题
Leetcode backtracking method
Dataframe (1): introduction and creation of dataframe
Nested method, calculation attribute is not applicable, use methods
LeetCode-54
Record the process of configuring nccl and horovod in these two days (original)
5. Oracle TABLESPACE
[rust notes] 15 string and text (Part 1)
MySQL advanced part 1: stored procedures and functions
Sqlmap tutorial (1)
In depth analysis of for (VaR I = 0; I < 5; i++) {settimeout (() => console.log (I), 1000)}