Topic:
When I was in college ten years ago, China introduced a lot of movies from abroad every year, including a movie called "The Game of the Brave" (English Name: Zathura), and until now I was still impressed by some of the computer stunts in the movie.
Today, everyone chooses to take the machine test, is a kind of brave (brave) choice; This short semester, we are talking about game (games) topic, so, everyone is playing "brave game", which is why I named this topic.
Of course, in addition to "brave", I also hope to see "good faith", no matter how the test results, want to see is a real result, I also believe that we can certainly do it ~
What is the first game the brave people want to play? Quite simply, it is defined as:
1, the game is a two-person game;
2, there are a lot of stones have n;
3, the two people take turns;
4, each step can take away 1...m of stones;
5, the first to take the light of the side of the stone to win;
If both sides of the game are using the optimal strategy, please output which one will win.
Input
The input data first consists of a positive integer C (c<=100), which indicates that there is a C set of test data.
Each set of test data contains a row of two integers n and m (1<=n,m<=1000), and the meanings of N and M are described in the topic.
Output
If the first person can win, please output "", otherwise output "second", the output of each instance occupies one row.
Sample Input
2 23 2) 4 3
Sample Output
First Second Test instructions:.. As above analysis: Ba Shi game —————— only a bunch of n items, two people take turns from this pile of goods, the provisions of at least one at a time, a maximum of M, and finally take the light wins. Code:
1#include <cstdio>2 intMain ()3 {4 intn,m,c;5scanf"%d",&c);6 while(c--)7 {8scanf"%d%d",&n,&m);9 intans,cnt;Tenans=n% (m+1); One if(ans==0) A { -printf"second\n"); - } the Else if(ans<m+1) - { -printf"first\n"); - } + } - return 0; +}
View Code
HDU 1846---ba Shi game