HDOJ 3032 Nim or not Nim? (博弈 :SG)
2012-09-14 20:55
441 查看
//HDOJ 3032 Nim or not Nim? (博弈 :SG) /* 题意:有n堆石子,每次可以选择一堆,执行一下操作: 1、取走至少一个 2、如果这堆石子大于一个,可以将其分成2堆,每堆至少一个 取走最后一个的胜利 思路:在Nim的基础上增加了一种操作,无法直接使用Nim的做法,尝试找规律 易得sg(0) = 0; sg(1) = 1; 当一堆石子有2个的时候,其后继状态有0,1,(1,1), (1,1)表示分成2堆,每堆1个 所以sg(2) = 2; 同理推断可得: sg(1)=1; sg(2)=2; sg(3)=4; sg(4)=3; sg(5)=5; sg(6)=6; sg(7)=8; sg(8)=7; ...规律出现。 */ #include<stdio.h> #include<string.h> #include<stdlib.h> int T,n; int bx[] = {-1,0,0,1}; int main(){ int i,ans,tmp; scanf("%d",&T); while(T--){ scanf("%d",&n); ans = 0; for(i = 1; i <= n; ++i){ scanf("%d",&tmp); if(tmp){ ans ^= (tmp+bx[tmp%4]); } } puts(ans?"Alice":"Bob"); } return 0; }
相关文章推荐
- HDU 3032 Nim or not Nim?(博弈 SG打表找规律)
- HDU 3032 Nim or not Nim?(博弈,SG打表找规律)
- HDOJ3032 Nim or not Nim? (sg打表)
- hdu 3032 Nim or not Nim? (SG,然后找规律)
- HDU 3032 Nim or not Nim? SG打表找规律
- (HDU 3032) Nim or not Nim(SG函数、博弈)
- HDU 3032 Nim or not Nim? [Multi-SG]
- hdu 3032 Nim or not Nim? (SG打表找规律)
- HDU 3032 Nim or not Nim? (博弈之求SG函数)
- hdoj3032 Nim or not Nim?( 可分解尼姆 )
- HDU 3032 (Nim博弈变形) Nim or not Nim?
- hdu 3032 Nim or not Nim?(搜索打SG表)
- HDU 3032 Nim or not Nim?(Multi_SG,打表找规律)
- hdu 3032 Nim or not Nim? 博弈(SG定理+找规律)
- 【HDU3032】【Lasker's Nim(一种Nim游戏)】Nim or not Nim? Multi-SG博弈、打表
- HDU 3032 - Nim or not Nim?(SG)
- HDU 3032 Nim or not Nim?(博弈,打表找规律)
- HDOJ 3032 Nim or not Nim?
- HDU 2311-Nim or not Nim?(Nim博弈-打sg表找规律)
- HDU 3032 Nim or not Nim? (需求的游戏SG功能)