51nod-1067 Bash Game V2

Source: Internet
Author: User
Tags time limit
1067 Bash game V2 base time limit: 1 seconds space limit: 131072 KB Score: 10 Difficulty: 2-level algorithm problem collection attention to a heap of stones total N. A B Two people take turns, a take first. Each time can only take 1,3,4, to get the last 1 stones of the people to win. Suppose a B is very clever, there is no mistake in the process of taking the stone. Give N and ask who can win the game at the end. For example n = 2. A can only take 1, so B can get the last 1 stones. Input
Line 1th: A number t that represents the number of numbers that are later used as input tests. (1 <= T <= 10000)
2-t + 1 lines: 1 numbers per line N. (1 <= N <= 10^9)
Output
A total of T-lines, if a WINS output A, if B wins output B.
Input example
3
2
3
4
Output example
B
a
a
Idea: The game problem to find strange situation is good (must defeat the situation) first can be seen 2. Is a must defeat, then 5 because 5 regardless of 1 2 4 What value, can not be the opponent to face the strange situation, then the 7,9, 11, 16 himself will be able to see the law +2 + 5 +2 + 5 So find the law is Can
#include <iostream>
#include <stdio.h>
using namespace std;

int main ()
{
    int T;
    cin>>t;
    while (t--)
    {
        int n;
        cin>>n;

        if (n%7==0| | n%7==2)
            cout<< "B" <<endl;
        else
            cout<< "A" <<endl;
    }
   /* int i=1,j=0;
    int a=2;
    while (a<100)
    {
        if (j>=i)
        {
            i++;
            a+=2;
        }
        else
        {
            J + +;
            a+=5;
        }
        cout<<a<<endl;
    } */
    return 0;
}


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.