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. vc控制台程序关闭事件时的正确处理方式

    百度可以找到很多关于这个问题解决的方法 关键控制台API函数:SetConsoleCtrlHandler 在支持C++ 11以上的编译器中,你可以这么做. SetConsoleCtrlHandler( ...

  2. 联盛德 HLK-W806 (六): I2C驱动SSD1306 128x64 OLED液晶屏

    目录 联盛德 HLK-W806 (一): Ubuntu20.04下的开发环境配置, 编译和烧录说明 联盛德 HLK-W806 (二): Win10下的开发环境配置, 编译和烧录说明 联盛德 HLK-W ...

  3. C#表格,表格信息、GridView使用。

    page: <%@ Control Language="C#" AutoEventWireup="true" CodeFile="test1.a ...

  4. 巩固javaweb的第十九天

    巩固内容: 使用 form 元素 使用 form 元素封装要提交的信息 要向服务器提交信息,需要使用 form 元素,所有要提交的信息都应该在 form 内部.在 注册界面中,所有要输入的信息都位于 ...

  5. springcloud - alibaba - 3 - 整合config - 更新完毕

    0.补充 1.需求 如果我有这么一个请求:我想要gitee中的配置改了之后,我程序yml中的配置也可以跟着相应产生变化,利用原生的方式怎么做?一般做法如下: 而有了SpringCloud-alibab ...

  6. 2016广东工业大学新生杯决赛 A-pigofzhou的巧克力棒

    题目:GDUTOJ | pigofzhou的巧克力棒 (gdutcode.cn) 之前看了大佬博客的题解,一直没懂(我太菜了),后来听了朋友@77的讲解,终于懂了. 和拆分出2的n次方不一样,这是一种 ...

  7. Mybatis-运行原理

    一.mybatis分层图 二.运行流程 根据全局配置文件创建sqlSessionFactory对象 根据全局配置文件的io流来构建SqlSessionFactoryBuilder对象: 解析(XmlC ...

  8. CentOS Linux下编译安装MySQL

    本文参考张宴的Nginx 0.8.x + PHP 5.2.13(FastCGI)搭建胜过Apache十倍的Web服务器(第6版)[原创]完成.所有操作命令都在CentOS 6.4 64位操作系统下实践 ...

  9. Java poi导出设置 Excel某些单元格不可编辑

    小白的总结,大神勿喷:需要转载请说明出处,如果有什么问题,欢迎留言 一.需求: 1.某一列 .某一行或某些单元格不可编辑,其他列可以编辑 二.期间遇到的问题 1.无法设置成不可编辑 2.设置为不可编辑 ...

  10. vue文件上传及压缩(canvas实现压缩)

    // 读取文件结果 afterRead(files) { let that = this; let file = files.file; if (file === undefined) { retur ...