lightoj 1020 (博弈)

时间:2023-03-09 06:02:38
lightoj 1020 (博弈)

思路:很简单的博弈,找出每个人先拿的必胜态进行状态转移即可。

#include<cstdio>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
int t, n, CASE(0);
char str[10];
scanf("%d", &t);
while(t--){
printf("Case %d: ", ++CASE);
scanf("%d%s", &n, str);
if(str[0] == 'B'){
if(n % 3) printf("Bob\n");
else printf("Alice\n");
}else{
if(n % 3 != 1) printf("Alice\n");
else printf("Bob\n");
}
}
return 0;
}