Race 19 freshmen who are more nb

Topic Description: There are a total of N pile of stones. syx xxh two people take turns, syx acquire. Every time take a minimum, take the most K stars, got the last one stone man win. syx xxh are very smart, the process will not take stones mistakes. Given N and K, and asked who won the last race. For example N = 3, K = 2. Regardless of syx take, xxh can get the last one stone.
Input format: Line 1: a number T, the number of the number of tests later used as an input representation. (1 <= T <= 10000 ) of 2 - T + 1 rows: 2 per row number N, K. Separated by a space. (1 <= N, K < = 10 ^ 9)
Input Format: T total line, if the winning output syx syxnb, if the winning output xxh xxhnb.
Sample
Input 432,427,383
output xxhnb syxnb syxnb xxhnb

Code

#include<bits/stdc++.h>

using namespace std;

int main () {

int T,n,k;

 cin>>T;
 for(int i=1; i<=T; i++) {
  cin>>n>>k;
  if(n%(k+1)==0) {
   cout<<"xxhnb"<<"\n";
  } else
   cout<<"syxnb"<<"\n";
 }
 return 0;
}

Bash Game: only a pile of n items, two people take turns extract from stack items, each at least take a predetermined, take up the m. Finally, light extraction by winning.
Obviously, if n = m + 1, then since a maximum number of m can, therefore, no matter how many first take away persons, who can after taking away a remaining items, which win. So we find that the rules of how to win: If n = (m + 1) r + s, (r is an arbitrary natural number, s≤m), then the first taker to take a s article, if after taking away by k ( ≤M) th, the first take away by re-m + 1-k th result, the remaining (m + 1) (r-1) th, after maintaining such emulated, then the first taker certainly win. In short, to keep leaving multiple (m + 1) to the opponent can finally win.
This game can also be a disguised form of play: Two people reported that the number of turns, each at least a newspaper, reported that up to ten, who can register 100 wins.
For Bash game, so we require, if the last person to take the light output, so how will it?
n% (m + 1) == 0 then the flip victory
Just get re-determine the policy, so it is not simply the opposite row

 

Guess you like

Origin www.cnblogs.com/QingyuYYYYY/p/11616387.html