Simple game of Hdu 1846 Brave game

Source: Internet
Author: User

Problem description A decade ago, China introduced a number of films 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 data first contains 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 export "second", otherwise output "", the output of each instance occupies one row.

Sample Input223 24 3

Sample Outputfirstsecond
#include <iostream>using namespacestd;intMain () {intn,m; intT; CIN>>T;  while(t--) {cin>>n>>m; if(n<=m) {cout<<" First"<<Endl; }        Else if(n% (m+1)==0) {cout<<"Second"<<Endl; }        Elsecout<<" First"<<Endl; }    return 0;}

Simple game of Hdu 1846 Brave game

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.