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
");
            else printf("Alice
");
        }else{
            if(n % 3 != 1) printf("Alice
");
            else printf("Bob
");
        }
    }
    return 0;
}


原文地址:https://www.cnblogs.com/anhuizhiye/p/3933129.html