fzu 2221 Running man Mathematical Thinking

Ideas:

Given the number of two teams, a best-of-three-game system is used. The runningman wins with the same number of players. No matter how the opponent arranges, ask whether the runningman will win.

Assuming that the number of the other party is m, the discussion is divided into two cases of odd and even numbers.

In extreme cases, the other party uses 0 to treat the largest number of runningman. Runningman has to win one of the remaining two games.

The other party arranges --- 0 , x , y , x>=y.

man        --- a , b , c ,a>=b>=c.

#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <queue>
#include <vector>
#include <cmath>
#include <stack>
#include <iostream>
using namespace std;

int main(void)
{
    int T, n, m;
    cin >> T;
    while (T--){
        cin >> n >> m;
        if ( m%2==1&& n>=(m/2)*3 || m%2==0 && n>=(m/2)*3-1 ) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }

    return 0;
}

(x,y) corresponds to (1,m-1),(2,m-2),...,(m/2,m/2), then abc is (m/2,m/ 2,m/2-1) can be the smallest number to guarantee victory.

When m is odd, it can also be analyzed correspondingly as (m/2,m/2,m/2) 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324734602&siteId=291194637