您的位置:首页 > 运维架构 > Shell

51nod 1067 Bash游戏 V2

2017-08-13 20:54 316 查看
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");

}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: