• Brave Game HDU


    十年前读大学的时候,中国每年都要从国外引进一些电影大片,其中有一部电影就叫《勇敢者的游戏》(英文名称:Zathura),一直到现在,我依然对于电影中的部分电脑特技印象深刻。
    今天,大家选择上机考试,就是一种勇敢(brave)的选择;这个短学期,我们讲的是博弈(game)专题;所以,大家现在玩的也是“勇敢者的游戏”,这也是我命名这个题目的原因。
    当然,除了“勇敢”,我还希望看到“诚信”,无论考试成绩如何,希望看到的都是一个真实的结果,我也相信大家一定能做到的~

    各位勇敢者要玩的第一个游戏是什么呢?很简单,它是这样定义的:
    1、  本游戏是一个二人游戏;
    2、  有一堆石子一共有n个;
    3、  两人轮流进行;
    4、  每走一步可以取走1…m个石子;
    5、  最先取光石子的一方为胜;

    如果游戏的双方使用的都是最优策略,请输出哪个人能赢。

    Input输入数据首先包含一个正整数C(C<=100),表示有C组测试数据。
    每组测试数据占一行,包含两个整数n和m(1<=n,m<=1000),n和m的含义见题目描述。
    Output如果先走的人能赢,请输出“first”,否则请输出“second”,每个实例的输出占一行。Sample Input

    2
    23 2
    4 3

    Sample Output

    first
    second
    从n<=m和n=m+1思考,,
    #include <bits/stdc++.h>
    #include<iostream>
    #include<cstdio>
    #include<cmath>
    #include<cstring>
    #include<algorithm>
    #include<queue>
    #include<map>
    #include<set>
    #include<vector>
    #include<iomanip>
    using namespace std;
    typedef long long ll;
    const ll inf = 1e18;
    const int mod = 998244353;
    const double eps = 1e-8;
    const int mx = 3e6+1e3; //check the limits, dummy
    typedef pair<int, int> pa;
    const double PI = acos(-1);
    ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
    ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
    bool isprime(int n) { if (n <= 1)return 0; for (int i = 2; i * i <= n; i++)if (n % i == 0)return 0; return 1; }
    #define swa(a,b) a^=b^=a^=b
    #define re(i,a,b) for(int i=(a),_=(b);i<_;i++)
    #define rb(i,a,b) for(ll i=(a),_=(b);i>=_;i--)
    #define clr(a,b) memset(a, b, sizeof(a))
    #define lowbit(x) ((x)&(x-1))
    #define mkp make_pair
    //inline ll qpow(ll a, ll b) { return b ? ((b & 1) ? a * qpow(a * a % mod, b >> 1) % mod : qpow(a * a % mod, b >> 1)) % mod : 1; }
    //inline ll qpow(ll a, ll b, ll c) { return b ? ((b & 1) ? a * qpow(a * a % c, b >> 1) % c : qpow(a * a % c, b >> 1)) % c : 1; }
    void ca(int kase, int ans) { cout << "Case #" << kase << ": " << ans << endl; }
    void sc(int& x) { scanf("%d", &x); }void sc(int64_t& x) { scanf("%lld", &x); }void sc(double& x) { scanf("%lf", &x); }void sc(char& x) { scanf(" %c", &x); }void sc(char* x) { scanf("%s", x); }
    int n, m, t, k;
    int a,mp[mx], sum, b,tmp,cnt=1,ans[mx],q[mx];
    int main()
    {
        ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
        cin >> t;
        while (t--) {
            cin >> a >> b;
            if (a%(b + 1) == 0)cout << "second" << endl;
            else cout << "first" << endl;
        }
        return 0;
    }
  • 相关阅读:
    用word2010发个blog
    停止调试无法关闭控制台
    D11.5.8,Lingo中不支持AS3的ExternalInterface接口
    Lingo03 通用脚本和自定义handler
    Lingo01 术语
    Lingo09 Sprite
    Lingo动态创建script member
    tut11脚本基础
    诡异失败的导入对话框
    Lingo3D01 3D Cast Member的组成
  • 原文地址:https://www.cnblogs.com/xxxsans/p/12862565.html
Copyright © 2020-2023  润新知