51nod1070(Bash游戏V4)

来源:互联网 发布:java sleep释放锁吗 编辑:程序博客网 时间:2024/06/08 12:33

题目链接: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;}