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.
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).
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.)
2 100 100 200 100
No Yes
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.
题意:输入n表示数据个数,接下来输入n组数据,a,b表示running man队员数和另一个队的人数。
游戏规则:3局两胜制,分三局,每局每队出一定的人数,若是相等,则running man队赢,每人最多参加一局比赛,人数多的队获胜,队伍分配在游戏开始前给出,比赛中不能更换,问runnning man, 是否能必定获得比赛胜利。
分析:
那么,在不知道对手如何安排人数的前提下,要想必胜,RunningMan的唯一选择就是每轮上场人数相同
这样就能应付对手可能安排某一轮人数多,某一轮人数少的情况,使得就算让对手赢也不能赢得太轻松,要尽可能地消耗对方人数
所以我们暂时假设RunningMan每轮上场人数为k
这就相当于,即便对手知道RunningMan队如何安排人数,但依旧是输
而我们之前已经知道RunningMan每轮上场人数为k
那对手要赢就要做到至少两场人数为k+1,更明智的,对手会放弃一轮,而把己方所有人投到某两轮中放手一搏
考虑到人是无法分割的整体,因此,我们对对手方的人数m进行奇偶性分类讨论:
⒈当m为偶数时,因为RunningMan队是平均分配人数的,所以对手方两轮人数分别为k,k(m=k+k,就算不是k,k也不要紧,后面接着分析)
此时RunningMan要想必定获胜且用的总人数最少,人数安排应该是k,k,k-1
这样的话,对手最多可以赢一场,即k>k-1,然后对手只剩k个人,无法赢另外两场,显然对手不会花更多的人去赢k-1的这轮,人越多越浪费
⒉当m为奇数时,对手方人数安排为k,k-1(m=k+k-1)
那么,RunningMan的人数安排为k-1,k-1,k-1就足够了
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <queue>
#include <string.h>
#include <math.h>
#include <cmath>
using namespace std;
const int N = 1005;
const int M = 1005;
const int inf = 1000000007;
const int mod = 1000003;
int main()
{
int t,n,m;
scanf("%d",&t);
while(t--)
{
scanf("%d%d",&n,&m);
if(m%2&&n>=m/2*3||m%2==0&&n>=m/2*3-1)
puts("Yes");
else
puts("No");
}
return 0;
}