RunningMan FZU - 2221 (思维!!)

RunningMan

FZU - 2221

ZB loves watching RunningMan! There's a game in RunningMan called 100 vs 100.

There are two teams, each of many people. There are 3 rounds of fighting, in each round the two teams send some people to fight. In each round, whichever team sends more people wins, and if the two teams send the same amount of people, RunningMan team wins. Each person can be sent out to only one round. The team wins 2 rounds win the whole game. Note, the arrangement of the fighter in three rounds must be decided before the whole game starts.

We know that there are N people on the RunningMan team, and that there are M people on the opposite team. Now zb wants to know whether there exists an arrangement of people for the RunningMan team so that they can always win, no matter how the opposite team arrange their people.


Input

The first line contains an integer T, meaning the number of the cases. 1 <= T <= 50.

For each test case, there's one line consists of two integers N and M. (1 <= N, M <= 10^9).

Output

For each test case, Output "Yes" if there exists an arrangement of people so that the RunningMan team can always win. "No" if there isn't such an arrangement. (Without the quotation marks.)

Sample Input
2
100 100
200 100
Sample Output
No
Yes
Hint

In the second example, the RunningMan team can arrange 60, 60, 80 people for the three rounds. No matter how the opposite team arrange their 100 people, they cannot win.

【题意】
两个队伍(其中一队为RunningMan)进行三轮制比赛

比赛规则如下:

①每轮比赛中,人数较多的一方获胜,人数相同时算RunningMan这队获胜

②参赛的每个人最多只能参加一轮比赛

③比赛采取三局两胜制,即赢了两轮比赛的队伍获胜

④三轮比赛的人数安排必须在总的比赛开始前给出,且不能更换

⑤显然,比赛开始前,每一队都不知道对方的人数安排情况

现在已知RunningMan队有n个人,另一队有m个人,问RunningMan队是否必定能够获得比赛最终的胜利

【类型】
思维考查

【分析】

那么,在不知道对手如何安排人数的前提下,要想必胜,RunningMan的唯一选择就是每轮上场人数相同

这样就能应付对手可能安排某一轮人数多,某一轮人数少的情况,使得就算让对手赢也不能赢得太轻松,要尽可能地消耗对方人数

所以我们暂时假设RunningMan每轮上场人数为k


这就相当于,即便对手知道RunningMan队如何安排人数,但依旧是输

而我们之前已经知道RunningMan每轮上场人数为k

那对手要赢就要做到至少两场人数为k+1,更明智的,对手会放弃一轮,而把己方所有人投到某两轮中放手一搏

考虑到人是无法分割的整体,因此,我们对对手方的人数m进行奇偶性分类讨论:

⒈当m为偶数时,因为RunningMan队是平均分配人数的,所以对手方两轮人数分别为k,k(m=k+k,就算不是k,k也不要紧,后面接着分析)

此时RunningMan要想必定获胜且用的总人数最少,人数安排应该是k,k,k-1

所以n的人数最少应该是3k-1,即n >= 3k-1,因为m是偶数所以k = m/2  所以这种情况应该是n >= m / 2 * 3 - 1

这样的话,对手最多可以赢一场,即k>k-1,然后对手只剩k个人,无法赢另外两场,显然对手不会花更多的人去赢k-1的这轮,人越多越浪费

⒉当m为奇数时,对手方人数安排为k,k-1(m=k+k-1)

那么,RunningMan的人数安排为k-1,k-1,k-1就足够了

所以这种情况下n >= 3 * (k-1) 因为m是奇数所以 m / 2 = k-1,所以n >= m / 2 * 3

code:

#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main(){
    int t,n,m;
    scanf("%d",&t);
    while(t--){
        scanf("%d%d",&n,&m);
        if(m % 2 == 1 && n >= m / 2 * 3 || m % 2 == 0 && n >= m / 2 * 3 - 1)
            puts("Yes");
        else
            puts("No");
    }
    return 0;
}


阅读更多
个人分类: 思维技巧
上一篇Chess For Three (模拟)
下一篇Knapsack problem FZU - 2214 (01背包变形)
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭