Problem 2221 RunningMan(fuzoj)
Problem 2221 RunningManAccept: 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
Sample Output
思路:贪心.
因为总共就分三个队,因为两个队都要选取最优的策略,不论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)的更多相关文章
- FZU Problem 2221 RunningMan(贪心)
一开始就跑偏了,耽误了很长时间,我和队友都想到博弈上去了...我严重怀疑自己被前几个博弈题给洗脑了...贪心的做法其实就是我们分两种情况,因为A先出,所以B在第一组可以选择是赢或输,如果要输,那直接不 ...
- FZU 2221—— RunningMan——————【线性规划】
Problem 2221 RunningMan Accept: 17 Submit: 52Time Limit: 1000 mSec Memory Limit : 32768 KB P ...
- FZU 2221 RunningMan(跑男)
Problem Description 题目描述 ZB loves watching RunningMan! There's a game in RunningMan called 100 vs 10 ...
- FZOJ--2221-- RunningMan(水题)
Problem 2221 RunningMan Accept: 4 Submit: 10 Time Limit: 1000 mSec Memory Limit : 32768 KB Pro ...
- CSU-2221 假装是区间众数(ST表模版题)
题目链接 题目 Description 给定一个非递减数列Ai,你只需要支持一个操作:求一段区间内出现最多的数字的出现次数. Input 第一行两个整数N,Q 接下来一行有N个整数,表示这个序列. 接 ...
- 1199 Problem B: 大小关系
求有限集传递闭包的 Floyd Warshall 算法(矩阵实现) 其实就三重循环.zzuoj 1199 题 链接 http://acm.zzu.edu.cn:8000/problem.php?id= ...
- 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 ...
- C - NP-Hard Problem(二分图判定-染色法)
C - NP-Hard Problem Crawling in process... Crawling failed Time Limit:2000MS Memory Limit:262144 ...
- Time Consume Problem
I joined the NodeJS online Course three weeks ago, but now I'm late about 2 weeks. I pay the codesch ...
随机推荐
- 对Javascript中的对象Object改变内存及其变量改变的图解
Object 存储变量时,变量属性的内存改变图解 左边: 对象的内存 中间:变量属性的内存 右边:属性值的内存 [图一]创建一个对象,存obj1 变量--里面存age 属性和属性值--12. ...
- dubbo 协议的 K8s pod 存活探针配置
背景 某项目采用微服务架构,dubbo 框架,K8s 方式部署. 其中 HTTP 协议由网关应用统一处理,大部分应用仅提供 dubbo 协议. 目标 应用某个实例(pod)状态异常时,尝试自动重启恢复 ...
- 日常Java 2021/10/1
正则表达式 \cx匹配由x指明的控制字符.例如,lcM匹配一个Control-M或回车符.x的值必须为A-Z或a-z之一.否则,将c视为一个原义的'℃'字符.\f匹配--个换页符.等价于\xOc和\c ...
- accurate, accuse
accurate accurate(不是acute)和precise是近义词,precise里有个pre,又和excise(切除, 不是exercise),concise一样有cise.Why? 准确 ...
- STM32代码常见的坑
1 混淆换行符\和除号/造成的坑 入坑代码: GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin ...
- oracle 日期语言格式化
TO_DATE ('17-JUN-87', 'dd-mm-yy', 'NLS_DATE_LANGUAGE = American')
- Output of C++ Program | Set 1
Predict the output of below C++ programs. Question 1 1 // Assume that integers take 4 bytes. 2 #incl ...
- 监测linux系统负载与CPU、内存、硬盘、用户数的shell脚本
本节主要内容: 利用Shell脚本来监控Linux系统的负载.CPU.内存.硬盘.用户登录数. 一.linux系统告警邮件脚本 # vim /scripts/sys-warning.sh #!/bin ...
- 前端两大框架 vue 和 react 的区别
1. 设计思想 vue: vue的官网介绍说vue是一种渐进式框架,采用自底向上增量开发的设计: react: 采用函数式编程,推崇纯组件,数据不可变,单向数据流: 2. 编写语法 vue: 采用单文 ...
- 基于Web的质量和测试度量指标
直观了解软件质量和测试的完整性 VectorCAST/Analytics可提供便于用户理解的web仪表盘视图来显示软件代码质量和测试完整性指标,让用户能够掌握单个代码库的趋势,或对比多个代码库的度量指 ...