UVALive/LA 5059 Play with Stones 组合游戏/SG定理
来源:互联网 发布:淘宝私人定制在哪打开 编辑:程序博客网 时间:2024/04/30 04:54
#include <iostream>using namespace std;#define LL long longLL SG(LL x){ return x%2==0?x/2:SG(x/2);}int main(){ LL T; cin>>T; while(T--) { LL i,n,a,v=0; cin>>n; for(i=0;i<n;i++) { cin>>a; v^=SG(a); } if(v)cout<<"YES"<<endl; else cout<<"NO"<<endl; } return 0;}/*组合游戏:一个状态是必败状态当且仅当它的所有后继都是必败状态 一个状态是必胜条件当且仅当它至少有一个后继是必败状态 组合游戏的和。假设有k个组合游戏G1,G2,...Gk,可以定义一个新游戏,在每个回合中,当前游戏可以任选一个子游戏Gi进行一次合法操作,而让其他游戏的局面保持不变,不鞥操作的游戏者输。这个新游戏称为G1,G2,...,G3的和 SG函数和SG定理。对于任意状态x,定义SG(x)=mex(S),其中S是x的后继状态的SG函数值集合,mex(S)表示不在S内的最小非负整数。SG(x)当且仅当x为必败状态.游戏和的SG函数SG函数等于各子游戏SG函数的Nim和。 Bouton定理:状态(x1,x2,x3)为必败状态当且仅当x1^x2^x3=0,称为Nim和。可看做SG定理在Nim游戏中的运用*//*通过SG定理求得SG函数,然后通过找规律解决问题,SG(n)=n/2(n为偶数),SG(n)=SG(n/2)(n为奇数)#include <iostream>#include <string.h>using namespace std;#define maxn 100int SG[maxn];int vis[maxn];int main(){ SG[1]=0; for(int i=2;i<=30;i++) { memset(vis,0,sizeof(vis)); for(int j=1;j*2<=i;j++)vis[SG[i-j]]=1; for(int j=0;;j++) if(!vis[j]) { SG[i]=j; break; } cout<<SG[i]<<endl; } return 0;}*/
- UVALive/LA 5059 Play with Stones 组合游戏/SG定理
- uvalive 5059 Playing With Stones(组合游戏,SG函数)@
- UVALive 5059 Play with Stones SG函数,难度较低
- 【LA 5059】 Playing With Stones|博弈论|SG函数
- La 5059 - Playing With Stones
- 组合游戏 - SG函数和SG定理
- 组合游戏 - SG函数和SG定理
- 石子游戏(Play with Stones)
- UVA 10561 Treblecross 组合游戏/SG定理
- uva10561 博弈 Treblecross 组合游戏/SG定理
- UVALive 5059 C Playing With Stones
- Nim游戏的一个扩展——51nod 1661 黑板上的游戏+LA 5059 Playing With Stones
- UVA1482:Playing With Stones(SG)
- UVA 12293 Box Game 组合游戏/SG定理+找规律
- LightOJ 组合游戏 SG函数 SG定理 1199 1296 1315 1229 1401
- HDU 1848 浅谈组合游戏博弈论及SG函数MEX推导SG定理
- uva 1378 A Funny Stone Game 博弈/组合游戏 sg定理
- 组合游戏中的SG函数
- C# 加密算法汇总
- TCP/IP协议基础之一
- ubuntu 安装 codeblocks 12.11 (或codeblocks 10.05 升级至12.11)
- 实现页面内容不能粘贴复制
- Webservice_23_SOAP的基于契约优先开发用户管理_添加异常
- UVALive/LA 5059 Play with Stones 组合游戏/SG定理
- jcaptcha验证码的使用
- Poj 2136 Vertical Histogram(打印垂直直方图)
- HashMap,LinkedHashMap,TreeMap的区别(精辟)
- ubuntu下html及java程序中文乱码解决方法
- ICE的异步方法调用
- fatal error C1083: 无法打开包括文件:“afxcontrolbars.h”: No such file or directory简单解决方法
- minicom: cannot open /dev/ttyUSB0:No such file or directory 或no such device的情况。
- c++ stack,queue,vector用法