HDU 1846 —— Brave Game

来源:互联网 发布:新手怎样做淘宝客 编辑:程序博客网 时间:2024/06/05 05:47
Brave Game

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

Problem Description
各位勇敢者要玩的第一个游戏是什么呢?很简单,它是这样定义的:
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
#include <cstdio>#include <iostream>using namespace std;int main (){    int C, n, m;    scanf("%d", &C);    while(C--) {        scanf("%d%d", &n, &m);        printf("%s\n", n%(m+1)==0 ? "second":"first");    }        return 0;}

 

0 0
原创粉丝点击