AcWing 894. 拆分-Nim游戏
2024-10-08 09:46:02
#include <cstring>
#include <iostream>
#include <algorithm>
#include <unordered_set>
using namespace std;
const int N = ;
int n;
int f[N];
int sg(int x) {
if (f[x] != -) return f[x];
unordered_set<int> S;
for (int i = ; i < x; i ++ )
for (int j = ; j <= i; j ++ )
S.insert(sg(i) ^ sg(j));
for (int i = ;; i ++ )
if (!S.count(i))
return f[x] = i;
}
int main() {
cin >> n;
memset(f, -, sizeof f);
int res = ;
while (n -- ) {
int x;
cin >> x;
res ^= sg(x);
}
if (res) puts("Yes");
else puts("No");
return ;
}
最新文章
- Number Sequence 分类: HDU 2015-06-19 20:54 10人阅读 评论(0) 收藏
- Debian 入门安装与配置2
- 【转载】关于Python中的yield
- (Loadrunner)Error: Failed to send data by channels - post message failed.(转)
- Latex之CJK中文书签乱码[转]
- opencv Installation in Linux and hello world
- 通过 yum update 将系统从CentOS 6.2 升级到 CentOS 6.6 及升级过程中的简单排错
- 安卓tabhost和子Activity通信方法
- 【bzoj 2159】Crash 的文明世界
- oracle 分析函数和开窗函数
- lnoi2019游记
- 机器学习系列-tensorflow-02-基本操作运算
- 使用Tr&#230;fɪk(traefik)来加速Qt在线更新
- FPGA editor 的使用之一 ------ Probe探针
- CSS3利用背景渐变和background-size配合完成渐变与条纹效果[持续更新中...]
- Cocos2d-x3.0触摸
- Django_Restframwork_序列号组件
- iOS学习笔记(6)——翻译苹果文档About Windows and Views
- Centos 安装 Oracle Java JDK
- 四则运算(Android)版