zoukankan      html  css  js  c++  java
  • HDU 5882 Balanced Game (水题)

    题意:问 nnn 个手势的石头剪刀布游戏是否能保证出每种手势胜率都一样。

    析:当每种手势的攻防个数完全相等才能保证平衡,所以容易得出 nnn 是奇数时游戏平衡,否则不平衡。

    也就是说打败 i 的和 i 打败的必须一样多,也就是说n-1 是个偶数。

    代码如下:

    #pragma comment(linker, "/STACK:1024000000,1024000000")
    #include <cstdio>
    #include <string>
    #include <cstdlib>
    #include <cmath>
    #include <iostream>
    #include <cstring>
    #include <set>
    #include <queue>
    #include <algorithm>
    #include <vector>
    #include <map>
    #include <cctype>
    #include <cmath>
    #include <stack>
    #define freopenr freopen("in.txt", "r", stdin)
    #define freopenw freopen("out.txt", "w", stdout)
    using namespace std;
    
    typedef long long LL;
    typedef pair<int, int> P;
    const int INF = 0x3f3f3f3f;
    const double inf = 0x3f3f3f3f3f3f;
    const double PI = acos(-1.0);
    const double eps = 1e-8;
    const int maxn = 1e3 + 5;
    const int mod = 1e9 + 7;
    const int dr[] = {-1, 0, 1, 0};
    const int dc[] = {0, 1, 0, -1};
    const char *de[] = {"0000", "0001", "0010", "0011", "0100", "0101", "0110", "0111", "1000", "1001", "1010", "1011", "1100", "1101", "1110", "1111"};
    int n, m;
    const int mon[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    const int monn[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    inline int Min(int a, int b){ return a < b ? a : b; }
    inline int Max(int a, int b){ return a > b ? a : b; }
    inline LL Min(LL a, LL b){ return a < b ? a : b; }
    inline LL Max(LL a, LL b){ return a > b ? a : b; }
    inline bool is_in(int r, int c){
        return r >= 0 && r < n && c >= 0 && c < m;
    }
    
    int main(){
        int T; cin >> T;
        while(T--){
            scanf("%d", &n);
            if(n & 1)  printf("Balanced
    ");
            else printf("Bad
    ");
        }
        return 0;
    }
    
  • 相关阅读:
    基于jquery的提示框JavaScript 插件,类Bootstrap
    css重点知识和bug解决方法
    小白初识js
    动态的将数据生成“表格”(京东商品),并具备搜索筛选工能
    原装js轮播图,鼠标移入停止轮播,移出继续轮播
    用js写九九乘法表格,附带背景颜色
    用js写直角三角形,等腰三角形,菱形
    关于两数组,求出两数组中相同的的对象
    好的js书写习惯
    前端之道
  • 原文地址:https://www.cnblogs.com/dwtfukgv/p/5879410.html
Copyright © 2011-2022 走看看