打表找规律即可。

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的更多相关文章

  1. 【找规律】Divide by Zero 2017 and Codeforces Round #399 (Div. 1 + Div. 2, combined) B. Code For 1

    观察一下,将整个过程写出来,会发现形成一棵满二叉树,每一层要么全是0,要么全是1. 输出的顺序是其中序遍历. 每一层的序号形成等差数列,就计算一下就可以出来每一层覆盖到的区间的左右端点. 复杂度O(l ...

  2. 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 ...

  3. 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 ...

  4. 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 ...

  5. 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 ...

  6. 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 ...

  7. 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 ...

  8. 【概率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 ...

  9. 【基数排序】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 ...

随机推荐

  1. [hdu 1067]bfs+hash

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1067 queue里面果然不能放vector,还是自己写的struct比较省内存…… #include& ...

  2. HDU4725:The Shortest Path in Nya Graph(最短路)

    The Shortest Path in Nya Graph Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K ...

  3. Codeforces Round #526 (Div. 2) C. The Fair Nut and String

    C. The Fair Nut and String 题目链接:https://codeforces.com/contest/1084/problem/C 题意: 给出一个字符串,找出都为a的子序列( ...

  4. nginx 静态文件支持跨域访问权限

    一.原生态 location ^~ /repurchase-web/ {          alias /var/www/webapps/repurchase-web/;        } 二.支持跨 ...

  5. IDEA中如何使用svn

    1.安装tortoiseSVN客户端时,这里一定要勾选上,否则使用时会报错. 2.安装好之后,想启用idea的SVN插件还需要在idea配置一下,file - setting 按钮打开设置界面 或者( ...

  6. eclipse怎样快速的给代码段添加try catch

    打开要进行异常处理的java代码页面. 选中要添加try..catch的代码段,然后点击鼠标右键,选择[Sourround With]选项. 然后选择[Try/Catch Block]或者[6 try ...

  7. bzoj4886 [Lydsy2017年5月月赛]叠塔游戏

    传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=4886 [题解] 跟bzoj4883:http://www.cnblogs.com/galax ...

  8. 游戏中的过程生成——元胞自动机 Celluar Automata 生成洞穴地形

    最近在学习过程生成技术,在这里写一些心得. 对于元胞自动机,我们这里只讨论输入是一副二维bool数组的情况,即大多数游戏中的情况. 一个元胞自动机,对于一个输入,给出一个同样格式的输出.输出中的每个点 ...

  9. 破解wifi时遇到rtl8187 - [phy1]SIOCSIFFLAGS: Name not unique on network

    当我使用我的ubuntu利用aircrack-ng套件进行wifi破解时 遇到如下问题 rtl8187 - [phy1]SIOCSIFFLAGS: Name not unique on network ...

  10. SEH

    @author: dlive SEH是Windows的异常处理机制,在程序源代码中使用__try,__catch,__finally关键字来具体实现. 但SEH与C++的try, catch异常处理不 ...