打表找规律即可。

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. 如何在数据访问层上提高js的执行效率

    本文讲到的是如何从数据访问层面上提高JS 代码的执行效率.总的来讲有以下几条原则: 函数中读写局部变量总是最快的,而全局变量的读取则是最慢的: 尽可能地少用with 语句,因为它会增加with 语句以 ...

  2. 文件格式转换神器-pandoc

    By francis_hao    Mar 11,2017 介绍 如果你需要在各种类型的文件中穿梭,那么你需要这把瑞士军刀-pandoc 它可以将各种常见的不常见的文件类型转换成另一种,我感兴趣的是在 ...

  3. CentOS 6通过yum升级Git

    By francis_hao    Mar 9,2017   在一个新机器上推送代码到github上时出现了下面的问题 error: The requested URL returned error: ...

  4. 第五届华中区程序设计邀请赛暨武汉大学第十四届校赛 网络预选赛 A

    Problem 1603 - Minimum Sum Time Limit: 2000MS   Memory Limit: 65536KB   Total Submit: 564  Accepted: ...

  5. Codeforces Round #348 (VK Cup 2016 Round 2, Div. 2 Edition) B

    B. Little Artem and Grasshopper time limit per test 2 seconds memory limit per test 256 megabytes in ...

  6. Codeforces 937.B Vile Grasshoppers

    B. Vile Grasshoppers time limit per test 1 second memory limit per test 256 megabytes input standard ...

  7. centos7上安装docker-ce社区版

    报错:Error: docker-ce-selinux conflicts with 2:container-selinux-2.12-2.gite7096ce.el7.noarch 转载:http: ...

  8. JRE集成到Tomcat

    将jdk集成到tomcat里面(不用客户安装JRE) 或者 tomcat使用指定的jdk_ 给客户安装软件的时候,也许客户不想你在人家机器的环境变量里设置来设置去,那么就要在tomcat里指定要使用的 ...

  9. Javadoc注释的用法

    Javadoc注释的用法   相关阅读:http://blog.163.com/hui_san/blog/static/5710286720104191100389/ Java 文档// 注释一行/* ...

  10. C++ 智能指针的简单实现

    智能指针的用处:在c++中,使用普通指针容易造成堆内存的泄露问题,即程序员会忘记释放,以及二次释放,程序发生异常时内存泄漏等问题,而使用智能指针可以更好的管理堆内存.注意,在这里智能指针是一个类而非真 ...