beloved_ACM

SB,NB,都是一个B.
posts - 29, comments - 2, trackbacks - 0, articles - 0
  C++博客 :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理

POJ_2234_多堆取石子游戏

Posted on 2011-09-10 01:45 成幸毅 阅读(404) 评论(0)  编辑 收藏 引用

每堆石子的SG函数就是它自己k.因为他的后继结点可以是0,1,2..k-1,所以此题直接异或即可,为什么异或,参考<<游戏策略>>朱全民的论文

#include <iostream>
#include 
<cstdio>
#include 
<cstdlib>
#include 
<vector>
#include 
<algorithm>
using namespace std;


int main() {
    
    
int a,b,n;
    
while(scanf("%d",&n) != EOF) {
     
int k = 0;
     
for(int i = 0; i < n; i++{
        scanf(
"%d",&a);
        k 
^= a;
     }

    
if(k) cout<<"Yes"<<endl;
    
else cout<<"No"<<endl;
    }

    
  
//  system("pause");
    return 0;
}


 


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理