您的位置:首页 > 其它

HDU 2509 Be the Winner

2012-04-18 19:31 204 查看
这题Nim博弈;这一就是要考虑全部为1的情况;

View Code

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<set>
#include<map>
#include<vector>
using namespace std;

int main(  )
{
int n ,m,t;
while( scanf( "%d",&n )==1 )
{
t = 0 ;
int flag = 0;
while( n -- )
{
scanf( "%d" ,&m );
if( m > 1 ) flag = 1;
t ^= m;
}
if( flag )
{
if( t== 0 ) puts( "No" );
else puts( "Yes" );
}
else
{
if( t ) puts( "No" );
else
puts( "Yes" );
}
}
//system( "pause" );
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: