Problem Description

题目描述

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.

ZB最近迷上了《Running Man》(韩)!跑男里有个游戏叫100 vs 100。

现在有两支队伍,每支队伍有若干人。三回合较量中,每轮两支队伍分别派出若干人比试。每回合中,派出人数较多的队伍获胜,如果两支队伍人数相同,则跑男队获胜。每人只能上场一次,三局两胜。注意,三回合的人数安排必须在游戏开始前决定。

我们知道跑男队有N人,并且敌方队伍有M人。现在ZB想要知道跑男队是否存在一种必胜的排法,让对手无可奈何。

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).

第一行有一个整数T,表示样例的数量。1 <= T <= 50。

每个测试样例只有一行,每行两个整数N、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.)

对于每个测试样例,如果存在跑男队必胜队排法则输出"Yes",否则输出"No"。(输出没有引号。)

Sample Input- 输入样例

Sample Output- 输出样例

2

100 100

200 100

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.

对于每个测试样例,如果存在跑男队必胜队排法则输出"Yes",否则输出"No"。(输出没有引号。)

【题解】

注意人数是>=1的。

那么对于敌方队伍来说,最优的策略就是:赢最少的,输最多的,剩下看脸。

所以这里设:

跑男队为 X = 3Xmin + C1   敌方队伍为 Y = 3Ymin + C2

为了对敌方队伍在第一波造成最大的消耗,这里的Xmin则尽可能大,所以C1=0。

或者说跑男队的组合可以以不变应万变,可以直接当成X = 3Xmin

(懒癌发作,证明略)

然后写出敌方队伍最优策略下跑男队还能获胜的式子

Y-(Ymin+1) ≤ (X-Xmin)/2

化简得:

2Y-2 ≤ X+Xmin

Y-1 ≤ 2 Xmin     (懒癌发作)

Y-1 ≤ (2/3)X

注意这里都是数学运算,int的除法会出现精度问题,可以用double解决。

或者化成整数形式3*Y ≤ 2*X+3 (int会越界,最大值40亿,int最大值21亿+,可以使用unsigned int或 __int64,并且使用无符号的时候注意减法运算)

【代码 C++】

 #include<cstdio>
int main(){
unsigned int x, y, t;
scanf("%u", &t);
while (t--){
scanf("%u%u", &x, &y);
if ( * y <= * x + ) puts("Yes");
else puts("No");
}
return ;
}

FZU 2221

FZU 2221 RunningMan(跑男)的更多相关文章

  1. FZU 2221—— RunningMan——————【线性规划】

     Problem 2221 RunningMan Accept: 17    Submit: 52Time Limit: 1000 mSec    Memory Limit : 32768 KB  P ...

  2. Problem 2221 RunningMan(fuzoj)

     Problem 2221 RunningMan Accept: 130    Submit: 404Time Limit: 1000 mSec    Memory Limit : 32768 KB ...

  3. FZU Problem 2221 RunningMan(贪心)

    一开始就跑偏了,耽误了很长时间,我和队友都想到博弈上去了...我严重怀疑自己被前几个博弈题给洗脑了...贪心的做法其实就是我们分两种情况,因为A先出,所以B在第一组可以选择是赢或输,如果要输,那直接不 ...

  4. D - 下个也是签到题 FZU - 2221(博弈)

    ZB loves watching RunningMan! There's a game in RunningMan called 100 vs 100. There are two teams, e ...

  5. FZOJ--2221-- RunningMan(水题)

    Problem 2221 RunningMan Accept: 4    Submit: 10 Time Limit: 1000 mSec    Memory Limit : 32768 KB Pro ...

  6. FZU 2137 奇异字符串 后缀树组+RMQ

    题目连接:http://acm.fzu.edu.cn/problem.php?pid=2137 题解: 枚举x位置,向左右延伸计算答案 如何计算答案:对字符串建立SA,那么对于想双延伸的长度L,假如有 ...

  7. FZU 1914 单调队列

    题目链接:http://acm.fzu.edu.cn/problem.php?pid=1914 题意: 给出一个数列,如果它的前i(1<=i<=n)项和都是正的,那么这个数列是正的,问这个 ...

  8. ACM: FZU 2105 Digits Count - 位运算的线段树【黑科技福利】

     FZU 2105  Digits Count Time Limit:10000MS     Memory Limit:262144KB     64bit IO Format:%I64d & ...

  9. FZU 2112 并查集、欧拉通路

    原题:http://acm.fzu.edu.cn/problem.php?pid=2112 首先是,票上没有提到的点是不需要去的. 然后我们先考虑这个图有几个连通分量,我们可以用一个并查集来维护,假设 ...

随机推荐

  1. C++线性方程求解

    介绍 程序SolveLinearEquations解决联立方程.该方案需要一个文本文件,其中包含输入和输出方程解决.这个项目是几年前我写在C#中http://www.codeproject.com/A ...

  2. TVideoGrabber如何将网络摄像头影像实时发布到网络

    在TVideoGrabber中如何将网络摄像头影像实时发布到网络?如何设置正在运行TVideoGrabber的一台电脑,同时通过另一台电脑在网络中实时的观看在线视频呢? 在这里称发送视频流的电脑为“m ...

  3. json校验

    直接百度:json在线解析  或  json.cnhttp://json.cn/ json格式校验的.这个更加简洁些.

  4. ARM多核处理器启动过程分析【转】

    转自:http://blog.csdn.net/qianlong4526888/article/details/27695173 版权声明:本文为博主原创文章,未经博主允许不得转载. 说明: 该流程图 ...

  5. yii2通过foreach循环遍历在一个用户组中取出id去另一表里查寻信息并且带着信息合并原数组信息---案例

    yii2通过foreach循环遍历在一个用户组中取出id去另一表里查寻信息并且带着信息合并元数组信息---案例 public function actionRandomLists(){ //查询到了所 ...

  6. RAC例子

    我个人非常推崇ReactiveCocoa,它就像中国的太极,太极生两仪,两仪生四象,四象生八卦,八卦生万物.ReactiveCocoa是一个高度抽象的编程框架,它真的很抽象,初看你不知道它是要干嘛的, ...

  7. IO流认识

    处理流是“连接”在已存在的流(节点流或处理流)之上,通过对数据的处理为程序提供更强大的读写能力.  BufferedWriter/BufferedReader(缓冲流)是处理流中的一种 OutputS ...

  8. C#:实现托盘(任务栏图标与托盘图标互斥)

    实现托盘(任务栏图标与托盘图标互斥),并且在点击任务栏图标时实现的最小化与点击最小化按钮分离. 具体如下: 1.向窗体上添加如下控件:MenuStrip menuStrip1, NotifyIcon ...

  9. include<stdio.h> 和include<iostream.h>的区别

    stdio 是C标准库里面的函数库 对应的基本都是标准输入输出等等C语言常用库的定义iostream是C++标准库的头定义, 对应的基本上是C++的输入输出相关库定义开发C程序用Stdio, C++用 ...

  10. css3 简单动画

    <script> <!-- var x,y,n=0,ny=0,rotINT,rotYINT function rotateDIV() { x=document.getElementB ...