hdu3389(阶梯博弈)

这个题有点意思。。

首先有2个条件的限制,分别是对2和3取膜比较难统一,所以直接对一个数%6讨论

然后可以发现,0和3之间相互转移,1和2之间相互转移,4和5之间相互转移,这样就可以把这些数对当成奇偶来处理,然后可以转化成阶梯博弈了。。

然后最先出现的模数是1,3,4,所以1,3,4为偶,2,5,6为奇,因此对所有2,5,6的石子堆做nim就可以了。。

 

 

/**
 *        ┏┓    ┏┓
 *        ┏┛┗━━━━━━━┛┗━━━┓
 *        ┃       ┃  
 *        ┃   ━    ┃
 *        ┃ >   < ┃
 *        ┃       ┃
 *        ┃... ⌒ ...  ┃
 *        ┃       ┃
 *        ┗━┓   ┏━┛
 *          ┃   ┃ Code is far away from bug with the animal protecting          
 *          ┃   ┃   神兽保佑,代码无bug
 *          ┃   ┃           
 *          ┃   ┃        
 *          ┃   ┃
 *          ┃   ┃           
 *          ┃   ┗━━━┓
 *          ┃       ┣┓
 *          ┃       ┏┛
 *          ┗┓┓┏━┳┓┏┛
 *           ┃┫┫ ┃┫┫
 *           ┗┻┛ ┗┻┛
 */
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define inc(i,l,r) for(int i=l;i<=r;i++)
#define dec(i,l,r) for(int i=l;i>=r;i--)
#define link(x) for(edge *j=h[x];j;j=j->next)
#define mem(a) memset(a,0,sizeof(a))
#define ll long long
#define eps 1e-12
#define succ(x) (1<<(x))
#define lowbit(x) (x&(-x))
#define sqr(x) ((x)*(x))
#define mid (x+y>>1)
#define NM 205
#define nm 60005
#define pi 3.1415926535897931
const int inf=2000000+5;
using namespace std;
ll read(){
    ll x=0,f=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
    while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
    return f*x;
}











int n,s,_x,ca;

int main(){
    int _=read();while(_--){
	n=read();s=0;
	inc(i,1,n){
	    _x=read();
	    if(i%6==0||i%6==2||i%6==5)s^=_x;
	}
	printf("Case %d: ",++ca);
	puts(s?"Alice":"Bob");
    }
    return 0;
}

 

 

 

 

 

 

Game

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1111    Accepted Submission(s): 788


 

Problem Description

Bob and Alice are playing a new game. There are n boxes which have been numbered from 1 to n. Each box is either empty or contains several cards. Bob and Alice move the cards in turn. In each turn the corresponding player should choose a non-empty box A and choose another box B that B

 

 

Input

The first line contains an integer T (T<=100) indicating the number of test cases. The first line of each test case contains an integer n (1<=n<=10000). The second line has n integers which will not be bigger than 100. The i-th integer indicates the number of cards in the i-th box.

 

 

Output

For each test case, print the case number and the winner's name in a single line. Follow the format of the sample output.

 

 

Sample Input

 

2 2 1 2 7 1 3 3 2 2 1 2

 

 

Sample Output

 

Case 1: Alice Case 2: Bob

 

 

Author

hanshuai@whu

 

 

Source

The 5th Guangting Cup Central China Invitational Programming Contest

 

 

Recommend

notonlysuccess   |   We have carefully selected several similar problems for you:  3387 3388 3390 3391 3393 

 

 

Statistic | Submit | Discuss | Note

你可能感兴趣的:(博弈论)