Bash游戏

来源:互联网 发布:疯狂java讲义代码 编辑:程序博客网 时间:2024/06/03 14:52

题目传送门


有一堆石子一共N个,两人轮流拿,最少拿1个,最多拿K个,最后拿完石子的获胜

如果N % (k+1) == 0,B必胜,
否则A必胜

代码如下:
#include <iostream>#include <algorithm>#include <cstring>#include <stdio.h>#include <string>#include <cmath>#define ll long long#define mem(name,value) memset(name,value,sizeof(name))using namespace std;const int maxn = 105;int dp[maxn][maxn];int main(){    int t;    cin >> t;    while(t--){        int n,k;        cin >> n >> k;        if(n % (k+1) == 0) cout << "B" <<endl;        else cout << "A" <<endl;    }    return 0;}



0 0
原创粉丝点击