POJ 1740 A New Stone Game(多堆博弈找规律)
2016-03-01 23:20
603 查看
传送门
//有n堆,AB轮流从n堆的一堆中移任意个,可以扔掉,也可以移给其他堆中的一堆 //最先移完的胜 //如果n堆中两两堆数目相等,那肯定是B胜 //但只要有非两两相同的,如xyz,A先, //A可以从最多的那堆(z)移y-x个到x堆,yyp,最终移走p的一定是A #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; int main() { int n,a[105]; while(scanf("%d",&n)&&n) { int aa,res=0,maxn=0; memset(a,0,sizeof(a)); for(int i=0;i<n;i++) { scanf("%d",&aa); maxn=max(maxn,aa); a[aa]++; } for(int i=0;i<=maxn;i++) { if(a[i]%2==1) { res=1; break; } } printf("%d\n",res); } return 0; }
相关文章推荐
- Linux驱动学习笔记(1)----模块
- 边看书边做边发挥-图书软件-1
- Java排序六:堆排序
- 紫书 p108 例题5-1
- Xcode 报错clang- error- linker command failed with exit code 1 (use -v to see invocation)总结
- 在 Mac 中开启自带的 Apache
- 老男孩28期运维张帅学习Linux决心书
- nginx命令:启动,停止及改变配置重启
- android docs 打开提速
- java菜鸟须知
- java httpclient 抓取网页 POST GET
- solr5.5配置IKAnalyzer分词器
- Mat简介 1
- HDU 2509 Be the Winner(取火柴博弈2)
- [转]理解$watch ,$apply 和 $digest --- 理解数据绑定过程
- 发送NOTIFY
- thinkphp使用问题
- (持续更新)Xamarin.Forms之常见的问题
- Swift Documentation
- springMVC-错误消息的显示和国际化