题目链接:点这里。
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<A && (A+B)%2=1 && (A+B)%3=0. Then, take an arbitrary number (but not zero) of cards from box A to box B. The last one who can do a legal move wins. Alice is the first player. Please predict who will win the game.
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
【题意】
n堆石子,每次选择两堆,如果满足(B < A&&(A+B)&1&&(A+B)%3==0),那么就可以将A中的任意数量的石子放在B中,不能进行操作的人败。问你最后谁会胜利,其中Alice先动。
【分析】
毫无头绪,直接看的题解,说是阶梯博弈,没学过,看了看,暂时明白了一点,但是还是不会证明过程。推荐一下大佬写的:链接
【代码】
#include <cstdio>
using namespace std;
int main()
{
int T;
int n;
int a;
scanf("%d",&T);
for(int z=1;z<=T;z++)
{
scanf("%d",&n);
int sum = 0;
for(int i = 1;i <= n;i++)
{
scanf("%d",&a);
if((i%3==0 && i%2==0) || i%3 == 2)
sum ^= a;
}
if(sum)printf("Case %d: Alice\n",z);
else printf("Case %d: Bob\n",z);
}
return 0;
}