【博弈论】【SG函数】【找规律】Divide by Zero 2017 and Codeforces Round #399 (Div. 1 + Div. 2, combined) E. Game of Stones
打表找规律即可。
1,1,2,2,2,3,3,3,3,4,4,4,4,4...
注意打表的时候,sg值不只与剩下的石子数有关,也和之前取走的方案有关。
//#include<cstdio>
//#include<set>
//#include<cstring>
//using namespace std;
//bool vis[16];
//int n,SG[16][1<<16];
//int sg(int x,int moved)
//{
// if(SG[x][moved]!=-1)
// return SG[x][moved];
// set<int>S;
// for(int i=1;i<=x;++i)
// if(!((moved>>(i-1))&1))
// S.insert(sg(x-i,moved|(1<<(i-1))));
// for(int i=0;;++i)
// if(S.find(i)==S.end())
// return SG[x][moved]=i;
//}
//int main()
//{
// scanf("%d",&n);
// for(int i=1;i<=n;++i)
// {
// memset(SG,-1,sizeof(SG));
// printf("%d:%d\n",i,sg(i,0));
// }
// return 0;
//}
#include<cstdio>
using namespace std;
int sg[100],n,ans,e;
int main()
{
// freopen("e.in","r",stdin);
int x;
for(int i=1;;++i)
{
for(int j=1;j<=i+1;++j)
{
sg[++e]=i;
if(e==60)
goto OUT;
}
}
OUT:
scanf("%d",&n);
for(int i=1;i<=n;++i)
{
scanf("%d",&x);
ans^=sg[x];
}
puts(ans ? "NO" : "YES");
return 0;
}
【博弈论】【SG函数】【找规律】Divide by Zero 2017 and Codeforces Round #399 (Div. 1 + Div. 2, combined) E. Game of Stones的更多相关文章
- 【找规律】Divide by Zero 2017 and Codeforces Round #399 (Div. 1 + Div. 2, combined) B. Code For 1
观察一下,将整个过程写出来,会发现形成一棵满二叉树,每一层要么全是0,要么全是1. 输出的顺序是其中序遍历. 每一层的序号形成等差数列,就计算一下就可以出来每一层覆盖到的区间的左右端点. 复杂度O(l ...
- Divide by Zero 2017 and Codeforces Round #399 (Div. 1 + Div. 2, combined)
C题卡了好久,A掉C题之后看到自己已经排在好后面说实话有点绝望,最后又过了两题,总算稳住了. AC:ABCDE Rank:191 Rating:2156+37->2193 A.Oath of t ...
- Divide by Zero 2017 and Codeforces Round #399 (Div. 1 + Div. 2, combined) C - Jon Snow and his Favourite Number
地址:http://codeforces.com/contest/768/problem/C 题目: C. Jon Snow and his Favourite Number time limit p ...
- Divide by Zero 2017 and Codeforces Round #399 (Div. 1 + Div. 2, combined) B. Code For 1
地址:http://codeforces.com/contest/768/problem/B 题目: B. Code For 1 time limit per test 2 seconds memor ...
- Divide by Zero 2017 and Codeforces Round #399 (Div. 1 + Div. 2, combined) D. Jon and Orbs
地址:http://codeforces.com/contest/768/problem/D 题目: D. Jon and Orbs time limit per test 2 seconds mem ...
- Divide by Zero 2017 and Codeforces Round #399 (Div. 1 + Div. 2, combined) A B 水 搜索
A. Oath of the Night's Watch time limit per test 2 seconds memory limit per test 256 megabytes input ...
- Divide by Zero 2017 and Codeforces Round #399 (Div. 1 + Div. 2, combined) A. Oath of the Night's Watch
地址:http://codeforces.com/problemset/problem/768/A 题目: A. Oath of the Night's Watch time limit per te ...
- 【概率dp】Divide by Zero 2017 and Codeforces Round #399 (Div. 1 + Div. 2, combined) D. Jon and Orbs
直接暴力dp就行……f(i,j)表示前i天集齐j种类的可能性.不超过10000天就能满足要求. #include<cstdio> using namespace std; #define ...
- 【基数排序】Divide by Zero 2017 and Codeforces Round #399 (Div. 1 + Div. 2, combined) C. Jon Snow and his Favourite Number
发现值域很小,而且怎么异或都不会超过1023……然后可以使用类似基数排序的思想,每次扫一遍就行了. 复杂度O(k*1024). #include<cstdio> #include<c ...
随机推荐
- HDU 4417 划分树写法
Problem Description Mario is world-famous plumber. His “burly” figure and amazing jumping ability re ...
- Google MapReduce中文版
英文原文链接: Google Map Reduce 译文原文链接: Google MapReduce中文版 Google MapReduce中文版 译者: alex 摘要 MapReduce是一个编程 ...
- java实现ssm框架的crud
上一篇博客写了通过表名获取数据库表结构的demo,现在我以此为基础实现了一个简单的通过数据库表结构生成对应的实体,通过读取mapper接口文件.mapping映射文件. service映射文件模板,替 ...
- 动态规划:数位DP
数位dp一般应用于: 求出在给定区间[A,B]内,符合条件P(i)的数i的个数 条件P(i)一般与数的大小无关,而与 数的组成 有关 例题是一道BZOJ1833,让求出区间所有整数每个数字出现的次数 ...
- 数据安全之MD5、SHA-1、CRC32区别
crc32 — 计算一个字符串的 crc32 多项式 生成 string 参数的 32 位循环冗余校验码多项式……:这句话从英文翻译过来的,不正确,准确的说应该是这么理解: 以32位循环冗余校验多项式 ...
- 密码字典生成工具crunch的简单使用
案例1: crunch 1 8 #生成最小1位,最大8位,由26个小写字母为元素的所有组合 案例2: crunch 1 6 abcdefg #生成最小为1,最大为6.由abcdefg为元素的所 ...
- 转:在android中button响应的两种方式
1. 在布局文件中添加button的监听名字 Android:onClick="buttonOnClick" 例如: <Button android:id="@+i ...
- [Leetcode Week4]H-Index
H-Index题解 原创文章,拒绝转载 题目来源:https://leetcode.com/problems/h-index/description/ Description Given an arr ...
- Linux ALSA介绍
1. 介绍 ALSA(即Advanced Linux Sound Architecture), 是目前Linux的主流音频体系结构, 提供了音频和MIDI的支持, 其架构图如下所示 TIP: 笔者的代 ...
- vue指令v-bind
v-bind用于绑定 html 属性,通常会将v-bind缩写(如"v-bind:class"可缩写成":class"): v-bind除了可以绑定字符串类型变 ...