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. 推荐一个latex简历模板的网站给大家

    http://www.rpi.edu/dept/arc/training/latex/resumes/ Using the LaTeX Resume Templates A group of resu ...

  2. kubernetes部署 flannel网络组件

    创建 flannel 证书和私钥flannel 从 etcd 集群存取网段分配信息,而 etcd 集群启用了双向 x509 证书认证,所以需要为 flanneld 生成证书和私钥. cat > ...

  3. 云原生PaaS平台通过插件整合SkyWalking,实现APM即插即用

    一. 简介 SkyWalking 是一个开源可观察性平台,用于收集.分析.聚合和可视化来自服务和云原生基础设施的数据.支持分布式追踪.性能指标分析.应用和服务依赖分析等:它是一种现代 APM,专为云原 ...

  4. 日常Java 2021/10/10

    多态就是同一个行为具有多个不同表现形式的能力 多态就是同一个接口,使用不同的实例而执行不同操作 多态的优点 1.消除类型之间的耦合关系 2.可替换性 3.可扩充性 4.接口性 5.灵活性 6.简化性 ...

  5. 【leetcode】1217. Minimum Cost to Move Chips to The Same Position

    We have n chips, where the position of the ith chip is position[i]. We need to move all the chips to ...

  6. Docker学习(一)——安装docker

    Suse12上安装docker   对于suse13.2之后的版本,因为docker已经被添加到了suse仓库中,直接使用sudo zypper install docker即可.   suse12不 ...

  7. centos 7 重新获取IP地址

    1.安装软件包 dhclient # yum install dhclient 2.释放现有IP # dhclient -r 3.重新获取 # dhclient 4.查看获取到到IP # ip a

  8. OpenStack之之一: 快速添加计算节点

    根据需求创建脚本,可以快速添加节点#:初始化node节点 [root@node2 ~]# systemctl disable NetworkManager [root@node2 ~]# vim /e ...

  9. 【Services】【Web】【LVS】lvs基础概念

    1.简介 1.1. 作者:张文嵩,就职于阿里 1.2. LVS是基础四层路由.四层交换的软件,他根据请求报文的目标IP和目标PORT将其调度转发至后端的某主机: 1.3. IPTABLES的请求转发路 ...

  10. 网络访问控制列表ACL(读懂这篇就基本够了,后面有配置案例)

    一.访问控制列表是什么? 访问控制列表(ACL)是一种基于包过滤的访问控制技术,它可以根据设定的条件对接口上的数据包进行过滤,允许其通过或丢弃.访问控制列表被广泛地应用于路由器和三层交换机,借助于访问 ...