51nod 1067 Bash游戏 V2

来源:互联网 发布:各种域名区别 编辑:程序博客网 时间:2024/05/16 06:26

http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1067

Bash游戏的变形,我是通过SG函数找出规律的:

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
0 1 0 1 2 3 2 0 1 0 1 0 1 2 3 2 0 1 0 1 2 3 2

所以n%7=0或 n%7=2就是奇异局面,则B胜,其它情况,A胜。

#include<iostream>#include<cstring>#include<stdio.h>#include<algorithm>#include<stack>#include<map>#include<string>using namespace std;int main(){    int t,n;   scanf("%d",&t);     while(t--)     {        scanf("%d",&n);        int u=n%7;        if(u==0||u==2)            printf("B\n");        else            printf("A\n");     }}
原创粉丝点击