hdu 1849 Rabbit and Grass SG定理(简单博弈)
来源:互联网 发布:51单片机视频教程 编辑:程序博客网 时间:2024/05/21 22:48
#include <cstdio>#include <cstring>#include <cmath>#include <map>#include <queue>#include <stack>#include <iostream>#include <algorithm>using namespace std;const int maxn=1010;int a;int main(){ int n; while(cin>>n) { if(n==0)break; int i,ans=0; for(i=0;i<n;i++) { cin>>a; ans^=a; } if(ans==0)cout<<"Grass Win!"<<endl; else cout<<"Rabbit Win!"<<endl; } return 0;}/* 简单博弈(组合游戏) 用SG定理解,求得Nim和就OK了,和hdu 1850差不多 sg值先写个程序打表,找下规律,得出sg[i]=i;*/
sg值打表:
#include <cstdio> #include <cstring> #include <cmath> #include <map> #include <queue> #include <stack> #include <iostream> #include <algorithm> using namespace std; const int maxn=1e3+10; int sg[maxn],vis[maxn]; void init() { int i,j; sg[0]=0; for(i=1;i<=100;i++) { memset(vis,0,sizeof(vis)); for(j=0;j<i;j++) vis[sg[j]]++; for(j=0;;j++) if(!vis[j]){sg[i]=j;break;} } for(i=1;i<=100;i++) cout<<sg[i]<<endl; } int main() { init(); }
- hdu 1849 Rabbit and Grass SG定理(简单博弈)
- HDU 1849 Rabbit and Grass 简单SG定理
- hdu 1849Rabbit and Grass(博弈)
- HDU(1849)Rabbit and Grass(博弈)
- HDU 1849 Rabbit and Grass(nim博弈)
- HDU 1849 Rabbit and Grass 【Nim博弈】
- HDU-1849-Rabbit and Grass【Nim博弈】
- hdu 1849 Rabbit and Grass Nim博弈
- [HDU](1849)Rabbit and Grass ---Nim博弈(博弈)
- hdu 1849 Rabbit and Grass(尼姆博弈)
- HDU 1849 Rabbit and Grass【尼姆博弈】
- hdu 1849 Rabbit and Grass(nim 博弈)
- HDU 1849 Rabbit and Grass 博弈Nim游戏
- HDU 1849-Rabbit and Grass(尼姆博弈)
- HDU 1849 Rabbit and Grass(尼姆博弈)
- HDU 1849 Rabbit and Grass(博弈入门)
- HDU 1849-Rabbit and Grass(尼姆博弈)
- hdu 1849 Rabbit and Grass(Nim博弈入门)
- 运算符重载 = 的注意
- 开启程序猿之路吧~~
- 如何在VMware虚拟机上安装Linux操作系统(Ubuntu)
- TCP/IP学习
- 平衡二叉树插入某个节点的方法
- hdu 1849 Rabbit and Grass SG定理(简单博弈)
- v5教程--数据集函数
- 一个小小的感染案例
- HDOJ 1000 A + B Problem
- struts2面试经常问到的几个问题
- Vbs也恶搞
- 为什么要学习C语言?
- SP2-0618: Cannot find the Session Identifier. Check PLUSTRACE role is enabled
- C++程序设计