标签:des style color os java io strong for ar
3 2 0 3 3 6 2 2 6 3 6 3 0
Case 1: Yes Case 2: No/* 以为很难,结果看了下人家的博客还是SG函数 Time:2014-8-27 21-18 */ #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> using namespace std; int Get_sg(int sum,int x){ int D=sqrt(sum)+1; while(D*D+D>=sum) D--;//找到必败的临界点 if(x>D)//D*D+D=sum D-1为必胜态,如果大于等于D,则必败,并且最小值是sum-D return sum-x;//返回能取得最小值即为sg值, //是减去 x不是D,即最少取的个数,写错了wa了好多次 else return Get_sg(D,x);//从临界值开始再向下寻找,找到返回 } int main(){ int N; int d=0; while(scanf("%d",&N),N){ int ans=0; int c,sum; for(int i=0;i<N;i++){ scanf("%d%d",&sum,&c); ans^=Get_sg(sum,c); } printf("Case %d:\n",++d); if(ans) printf("Yes\n"); else printf("No\n"); } return 0; }
标签:des style color os java io strong for ar
原文地址:http://blog.csdn.net/u013634213/article/details/38876441