51nod1070(Bash游戏V4)

题目链接:https://www.51nod.com/onlineJudge/questionCode.html#!problemId=1070

打表找规律:N在斐波那契数列中,B赢;不在,A赢。

#include <iostream>

using namespace std;

typedef long long LL;

const int maxn = 1e9;

LL f[50];

int main()
{
    f[0] = 0; f[1] = 1;
    for (int i=2; i<=50; i++){
        f[i] = f[i-1] + f[i-2];
    }

    int t;
    int n;
    cin >> t;
    while (t > 0){
        t--;

        cin >> n;
        bool flag = true;
        for (int i=0; i<50; i++){
            if (f[i] == n){
                flag = false;
                break;
            }
        }
        if (flag){
            cout << "A" << endl;
        }else{
            cout << "B" << endl;
        }
    }
    return 0;
}


猜你喜欢

转载自blog.csdn.net/qust1508060414/article/details/76383195