Brave Game

Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)

Total Submission(s): 14395 Accepted Submission(s): 9749

Problem Description

十年前读大学的时候,中国每年都要从国外引进一些电影大片,其中有一部电影就叫《勇敢者的游戏》(英文名称: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

Author

lcy

【分析】:

【代码】:

#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<stack>
#include<sstream>
#include<list>
#include<assert.h>
#include<bitset>
#include<numeric>
#define debug() puts("++++")
#define gcd(a,b) __gcd(a,b)
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define fi first
#define se second
#define pb push_back
#define sqr(x) ((x)*(x))
#define ms(a,b) memset(a,b,sizeof(a))
#define sz size()
#define be begin()
#define pu push_up
#define pd push_down
#define cl clear()
#define lowbit(x) -x&x
#define all 1,n,1
#define rep(i,a,b) for(int i=(a); i<(b); i++)
#define in freopen("in.in","r",stdin)
#define out freopen("out.out","w",stdout)
//#define mod 1000000007
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int> P;
const int INF = 0x3f3f3f3f;
const LL LNF = 1e18;
const int maxn = 1e5 + 20;
const int maxm = 1e6 + 10;
const double PI = acos(-1.0);
const double eps = 1e-8;
const int dx[] = {-1,1,0,0,1,1,-1,-1};
const int dy[] = {0,0,1,-1,1,-1,1,-1};
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};
#define ll long long
int main()
{
int t;
cin>>t;
while(t--)
{
int n,m;
cin>>n>>m;
int r = n%(m+1);
if(r>=1) cout<<"first"<<endl;
else cout<<"second"<<endl;
}
return 0;
}

HDU 1846 Brave Game【巴什博弈裸题】的更多相关文章

  1. HDU - 1846 Brave Game 巴什博弈

    思路:直接判断n是不是m+1的倍数,若是先手则输,否则赢. AC代码 #include <cstdio> #include <cmath> #include <algor ...

  2. (step8.2.4)hdu 1846(Brave Game——巴什博奕)

    题目大意:输入一个整数t,表示测试用例是.接着输入2个整数n,m.分别表示这堆石头中石头的个数,和每次所能取得最大的石头数.判断那一方为赢家 解题思路: 1)这是一道简单的巴什博弈: 所谓巴什博弈,是 ...

  3. HDU 1846 Brave Game 巴什博奕

    解题报告:Alice和Bob在做一个取石子游戏,有一堆n个石子,然后规定每个人每次最少要去1个石子,最多可以取m个石子,最后一次取完石子的人为胜. 巴什博奕,关键是找到必胜点和必败点,我们可以先列举出 ...

  4. HDU.1846 Brave Game (博弈论 巴什博弈)

    HDU.1846 Brave Game (博弈论 巴什博弈) 题意分析 巴什博奕裸题 博弈论快速入门 代码总览 include <bits/stdc++.h> using namespac ...

  5. POJ 2234 Matches Game(Nim博弈裸题)

    Description Here is a simple game. In this game, there are several piles of matches and two players. ...

  6. HDU 1846 Brave Game(巴什博弈超简单题)

    题目传送:http://acm.hdu.edu.cn/showproblem.php?pid=1846 Problem Description 十年前读大学的时候,中国每年都要从国外引进一些电影大片, ...

  7. HDU 1846 Brave Game(巴什博弈)

    题目链接: 传送门 Brave Game Time Limit: 1000MS     Memory Limit: 65536K 题目描述 各位勇敢者要玩的第一个游戏是什么呢?很简单,它是这样定义的: ...

  8. 题解报告:hdu 1846 Brave Game(巴什博弈)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1846 Problem Description 十年前读大学的时候,中国每年都要从国外引进一些电影大片, ...

  9. HDU 1846 Brave Game (博弈水题)

    题意:中文...你们懂得. 析:这个就是一个水题博弈,就是一个巴什博弈定理,直接就没有变,如果你们看过我写的那个,这个题绝对水过. 附地址:http://www.cnblogs.com/dwtfukg ...

随机推荐

  1. 《Cracking the Coding Interview》——第18章:难题——题目13

    2014-04-29 04:40 题目:给定一个字母组成的矩阵,和一个包含一堆单词的词典.请从矩阵中找出一个最大的子矩阵,使得从左到右每一行,从上到下每一列组成的单词都包含在词典中. 解法:O(n^3 ...

  2. USACO刷题之路,开始了

    几天前,重新开始刷题了. 重新刷题有几个原因: 1.曾经的OI经历,如今除了悟性高些.知识多些,大多已经遗忘.不希望真的让之前的OI水平就这么丢了. 2.越来越觉得,刷题真的是一件很开心的事情.大学中 ...

  3. windows 10的资源管理器不显示映射的网络驱动器怎么办?

    最近在使用映射网络驱动器的时候出现一个奇怪的现象.事情源于我在资源管理器里面映射了来自多个不同账号的网络驱动器.使用的是win10系统.映射不同账号的网络驱动器是不允许的.于是只能删掉其他账号和凭证重 ...

  4. Ubuntu系列问题

    一.Ubuntu16.04 intel_rapl : no valid rapl domains found in packge0 echo 'blacklist intel_rapl' >&g ...

  5. bayes学习笔记

    贝叶斯(BAYES)判别思想是根据先验概率求出后验概率,并依据后验概率分布作出统计推断.所谓先验概率,就是用概率来描述人们事先对所研究的对象的认识的程度:所谓后验概率,就是根据具体资料.先验概率.特定 ...

  6. UTXO是什么?

    以易于理解的方式解释了比特币交易中的"UTXO" UTXO 2017年11月1日 让我们看看当你发一点硬币时会发生什么. 比特币交易通过UTXO执行.通过在比特硬币的所有交易中新生 ...

  7. 使用SecureCRT设置linux系统登录的ssh公钥认证

    1.修改ssh配置文件/etc/ssh/sshd_configRSAAuthentication yes                             //使用RSA加密算法PubkeyAu ...

  8. P4712 「生物」能量流动

    由于题面$markdown$格式,博主太懒不想一个一个改,所以题面见此:戳 Solution: 本题的贪心思路比较有意思,完全考读题... 首先,因为总的能量来源是$a[0]$,所以可以理解为总能量守 ...

  9. Python实现队列

    队列的数据结构的主要结构:一个结点类和两个方法:出队列和进队列 class Node(object): def __init__(self,val): self.val = val self.next ...

  10. SpringMVC+MyBatis+Shiro 配置文件详解

    1.web.xml文件的配置 <?xml version="1.0" encoding="UTF-8"?> <web-app version= ...