zoukankan      html  css  js  c++  java
  • 51nod 1067 Bash游戏 V2 博弈

    基准时间限制:1 秒 空间限制:131072 KB 分值: 10 难度:2级算法题
     收藏
     关注
    有一堆石子共有N个。A B两个人轮流拿,A先拿。每次只能拿1,3,4颗,拿到最后1颗石子的人获胜。假设A B都非常聪明,拿石子的过程中不会出现失误。给出N,问最后谁能赢得比赛。
    例如N = 2。A只能拿1颗,所以B可以拿到最后1颗石子。
     
    Input
    第1行:一个数T,表示后面用作输入测试的数的数量。(1 <= T <= 10000)
    第2 - T + 1行:每行1个数N。(1 <= N <= 10^9)
    Output
    共T行,如果A获胜输出A,如果B获胜输出B。
    Input示例
    3
    2
    3
    4
    Output示例
    B
    A
    A

    Bash博弈的变形 Bash博弈变形之后基本变为找规律的题 这题也不例外 打个表之后就可以发现规律所在

    #include <iostream>
    #include <cstring>
    #include <cstdio>
    #include <algorithm>
    #include <queue>
    #include <vector>
    #include <iomanip>
    #include <math.h>
    #include <map>
    using namespace std;
    #define FIN     freopen("input.txt","r",stdin);
    #define FOUT    freopen("output.txt","w",stdout);
    #define INF     0x3f3f3f3f
    #define INFLL   0x3f3f3f3f3f3f3f
    #define lson    l,m,rt<<1
    #define rson    m+1,r,rt<<1|1
    typedef long long LL;
    typedef pair<int, int> PII;
    using namespace std;
    
    int T;
    
    int main() {
        scanf("%d", &T);
        while(T--) {
            int n;
            scanf("%d", &n);
            if(n % 7 == 0 || n % 7 == 2) printf("B
    ");
            else printf("A
    ");
    
    
        }
    
        return 0;
    }
    

      

  • 相关阅读:
    mysql 数据库 分表后 怎么进行分页查询?Mysql分库分表方案?
    mysql分库分区分表
    Mysql分表和分区的区别、分库和分表区别
    shell 浮点数和整数比较大小
    Domino's Pizza 点餐
    Long John Silver's 点餐
    韩国bibigo饺子做煎饺到方法
    其他的知名餐饮
    KFC 点餐
    Macdonald 点餐
  • 原文地址:https://www.cnblogs.com/Hyouka/p/7368007.html
Copyright © 2011-2022 走看看