Problem 2221 RunningMan

Accept: 130    Submit: 404
Time Limit: 1000 mSec    Memory Limit : 32768 KB

 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.

 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

思路:贪心.

因为总共就分三个队,因为两个队都要选取最优的策略,不论B队咋放,要使A队赢 。

设A队N人,B队M人。

设A第一次排a人,如果B这次要赢,根据最优就派(a+1)人,所以A下两场必需赢就可以得到(N-a)/2>=(M-a-1);因为B队已经赢了一次所以,可以把剩下的都放在一个队上。

假如B这次选择输,那他就在这次不派人,那么在下两场中A必须在赢一次,那么A只要在一次中派出所有剩下的人(N-a),因为还有一场A没有派人,所以B要会在那派上1人,

所以A要赢就有(N-a)>=M-1;这样两个不等式同时成立可以得(N+1>=3*M/2)

1 1 //############

 2  2 #include<stdio.h> 3  3 #include<algorithm> 4  4 #include<string.h> 5  5 #include<stdlib.h> 6  6 #include<math.h> 7  7 #include<iostream> 8  8 #include<cstdio> 9  9 #define sc(x) scanf("%I64d",&x)10 10 #define pr(x) printf("%I64d",x)11 11 #define prr(x) printf(" %I64d",x)12 12 #define prrr(x) printf("%I64d\n",x)13 13 typedef long long ll;14 14 const ll N=1e9+7;15 15 ll aa[5];16 16 ll bb[5];17 17 using namespace std ;18 18 int main(void)19 19 {20 20     ll i,j,k,p,q;21 21     sc(k);22 22     while(k--)23 23     {24 24         sc(p);25 25         sc(q);26 26         if((p+1)<q*3/2)27 27         {28 28             printf("No\n");29 29         }30 30         else31 31         {32 32             printf("Yes\n");33 33         }34 34     }35 35     return 0;36 36 }37  38  

2###

 2 #include<stdio.h> 3 #include<algorithm> 4 #include<string.h> 5 #include<stdlib.h> 6 #include<math.h> 7 #include<iostream> 8 #include<cstdio> 9 #define sc(x) scanf("%I64d",&x)10 #define pr(x) printf("%I64d",x)11 #define prr(x) printf(" %I64d",x)12 #define prrr(x) printf("%I64d\n",x)13 typedef long long ll;14 const ll N=1e9+7;15 ll aa[5];16 ll bb[5];17 using namespace std ;18 int main(void)19 {20     ll i,j,k,p,q;21     sc(k);22     while(k--)23     {24         sc(p);25         sc(q);26         ll mm=p/3;27         ll nn=q/2;28         aa[0]=mm;29         ll ss=p-mm;30         if(ss%2==0)31         {32             aa[1]=ss/2;33             aa[2]=ss/2;34         }35         else36         {37             aa[1]=ss/2;38             aa[2]=ss/2+1;39         }40         sort(aa,aa+3);41         if(nn>aa[0]&&nn>aa[1])42         {43             printf("No\n");44         }45         else46         {47             printf("Yes\n");48         }49     }50     return 0;51 }

Problem 2221 RunningMan(fuzoj)的更多相关文章

  1. FZU Problem 2221 RunningMan(贪心)

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

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

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

  3. FZU 2221 RunningMan(跑男)

    Problem Description 题目描述 ZB loves watching RunningMan! There's a game in RunningMan called 100 vs 10 ...

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

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

  5. CSU-2221 假装是区间众数(ST表模版题)

    题目链接 题目 Description 给定一个非递减数列Ai,你只需要支持一个操作:求一段区间内出现最多的数字的出现次数. Input 第一行两个整数N,Q 接下来一行有N个整数,表示这个序列. 接 ...

  6. 1199 Problem B: 大小关系

    求有限集传递闭包的 Floyd Warshall 算法(矩阵实现) 其实就三重循环.zzuoj 1199 题 链接 http://acm.zzu.edu.cn:8000/problem.php?id= ...

  7. No-args constructor for class X does not exist. Register an InstanceCreator with Gson for this type to fix this problem.

    Gson解析JSON字符串时出现了下面的错误: No-args constructor for class X does not exist. Register an InstanceCreator ...

  8. C - NP-Hard Problem(二分图判定-染色法)

    C - NP-Hard Problem Crawling in process... Crawling failed Time Limit:2000MS     Memory Limit:262144 ...

  9. Time Consume Problem

    I joined the NodeJS online Course three weeks ago, but now I'm late about 2 weeks. I pay the codesch ...

随机推荐

  1. 日常Java 2021/10/20

    Java提供了一套实现Collection接口的标准集合类 bstractCollection 实现了大部分的集合接口. AbstractList 继承于AbstractCollection并且实现了 ...

  2. day09 文件属性

    day09 文件属性 昨日回顾 yum底层原理: 第一步:执行yum install nginx安装命令 第二步:yum去/etc/yum.repos.d这个目录中 第三步:根据/etc/yum/re ...

  3. HTTP 之 options预请求

    一.HTTP一共有八种常见请求方法 get:参数在url上,浏览器长度有限制,不安全 post:参数不可见,长度不受限制 put:上传最新内容到指定位置 delete:删除请求的url所表示的资源 h ...

  4. ORACLE 按逗号拆分字符串为多行

    with t as (select '1,2,3,10,11,12' a from dual) select substr(a, decode(level - 1, 0, 0, instr(a, ', ...

  5. ORACLE CACHE BUFFER CHAINS原理

    原理图如下: 一个cache buffer chains 管理多个hash bucket,受隐含参数:_db_block_hash_buckets(控制管理几个hash bucket)

  6. js 时间戳转换为年月日时分秒的格式

    <script type="text/javascript"> var strDate = ''; $(function(){ // 获取时间戳 var nowDate ...

  7. java中子类继承父类什么?

    1.继承public和protected修饰的属性和方法,不管子类和父类是否在同一个包: 2.继承默认权限修饰符修饰的属性和方法,前提是子类和父类在同一个包.

  8. [BUUCTF]PWN——jarvisoj_tell_me_something

    jarvisoj_tell_me_something 附件 步骤: 例行检查,64位程序,开启了NX保护 运行一下程序,看看程序的大概流程 64位ida载入,shift+f12检索程序里的字符串 看到 ...

  9. AT4151 [ABC099B] Stone Monument 题解

    Content 一个村里有 \(999\) 个房子,第 \(i\) 个房子的高度为 \(1+2+...+i=\sum\limits_{j=1}^ij\).现在下了一场雪,给定相邻两个房子没被雪覆盖的高 ...

  10. java File 类对操作系统文件目录进行操作:增删查

    File类 1,概述 File类是java.io包下代表与平台无关的文件和目录,也就是说,如果希望在程序中操作文件和目录,都可以通过File类来完成. 2,构造方法 public File(Strin ...