Brave Game


Problem Description
When I was in college ten years ago, China imported some blockbuster movies from abroad every year. One of them was called "Jumanji" (English name: Zathura). Up to now, I still have some concerns about the computer in the movie. Impressive stunt.
Today, everyone's choice to take the computer-based exam is a brave choice; this short term, we are talking about the topic of game; therefore, everyone is now playing "Brave's Game", which is also my name. reason for this topic.
Of course, in addition to "brave", I also hope to see "integrity". No matter what the test results are, what I hope to see is a real result. I also believe that everyone can do it~

The first for all brave people to play What is a game? Very simple, it is defined like this:
1. This game is a two-player game;
2. There are a total of n stones in a pile;
3. Two players take turns;
4. Each step can take 1…m stones;
5. The first player to take all the stones is the winner;

if both sides of the game use the optimal strategy, please output who can win.
 

Input
The input data first contains a positive integer C (C<=100), indicating that there are C groups of test data.
Each set of test data occupies one line, including two integers n and m (1<=n, m<=1000). For the meaning of n and m, see the title description.
 

Output
If the first to go wins, output "first", otherwise, output "second", one line per instance.
 

Sample Input
 
   
223 24 3
 

Sample Output
 
   
firstsecond

naked bash game

#include <stdio.h>
#include <iostream>
using namespace std;
intmain()
{
	int c , n , m;
	scanf("%d" , &c);
	while(c--)
	{
		scanf("%d %d" , &n , &m);
		int flag = n %(m+1);
		if(flag == 0)
		{
			printf("second\n");
		}
		else
		{
			printf("first\n");
		}
	}
	return 0;
}

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326805801&siteId=291194637