此文章可以使用目录功能哟↑(点击上方[+])

 FZU Problem 2221 RunningMan

Accept: 0    Submit: 0
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

 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.

 Problem Idea

解题思路:

【题意】
两个队伍(其中一队为RunningMan)进行三轮制比赛

比赛规则如下:

①每轮比赛中,人数较多的一方获胜,人数相同时算RunningMan这队获胜

②参赛的每个人最多只能参加一轮比赛

③比赛采取三局两胜制,即赢了两轮比赛的队伍获胜

④三轮比赛的人数安排必须在总的比赛开始前给出,且不能更换

⑤显然,比赛开始前,每一队都不知道对方的人数安排情况

现在已知RunningMan队有n个人,另一队有m个人,问RunningMan队是否必定能够获得比赛最终的胜利

【类型】
思维考查

【分析】

那么,在不知道对手如何安排人数的前提下,要想必胜,RunningMan的唯一选择就是每轮上场人数相同

这样就能应付对手可能安排某一轮人数多,某一轮人数少的情况,使得就算让对手赢也不能赢得太轻松,要尽可能地消耗对方人数

所以我们暂时假设RunningMan每轮上场人数为k

这就相当于,即便对手知道RunningMan队如何安排人数,但依旧是输

而我们之前已经知道RunningMan每轮上场人数为k

那对手要赢就要做到至少两场人数为k+1,更明智的,对手会放弃一轮,而把己方所有人投到某两轮中放手一搏

考虑到人是无法分割的整体,因此,我们对对手方的人数m进行奇偶性分类讨论:

⒈当m为偶数时,因为RunningMan队是平均分配人数的,所以对手方两轮人数分别为k,k(m=k+k,就算不是k,k也不要紧,后面接着分析)

此时RunningMan要想必定获胜且用的总人数最少,人数安排应该是k,k,k-1

这样的话,对手最多可以赢一场,即k>k-1,然后对手只剩k个人,无法赢另外两场,显然对手不会花更多的人去赢k-1的这轮,人越多越浪费

⒉当m为奇数时,对手方人数安排为k,k-1(m=k+k-1)

那么,RunningMan的人数安排为k-1,k-1,k-1就足够了

分析完毕

【时间复杂度&&优化】
O(1)

题目链接→FZU Problem 2221 RunningMan

 Source Code

/*Sherlock and Watson and Adler*/
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<queue>
#include<stack>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<bitset>
#include<cmath>
#include<complex>
#include<string>
#include<algorithm>
#include<iostream>
#define eps 1e-9
#define LL long long
#define PI acos(-1.0)
#define bitnum(a) __builtin_popcount(a)
using namespace std;
const int N = 1005;
const int M = 1005;
const int inf = 1000000007;
const int mod = 1000003;
int main()
{int t,n,m;scanf("%d",&t);while(t--){scanf("%d%d",&n,&m);if(m%2&&n>=m/2*3||m%2==0&&n>=m/2*3-1)puts("Yes");elseputs("No");}return 0;
}

菜鸟成长记

FZU Problem 2221 RunningMan(思维考查)——第六届福建省大学生程序设计竞赛-重现赛相关推荐

  1. 第六届福建省大学生程序设计竞赛(FZU2213—FZU2221)

    from:piaocoder Common Tangents(两圆之间的公公切线) 题目链接: http://acm.fzu.edu.cn/problem.php?pid=2213 解题思路: 告诉你 ...

  2. 挑战程序设计竞赛_我系首次参加第六届中国大学生程序设计竞赛网络预选赛

    点击上方蓝字关注  「龙外信息工程系」 讲述有温度的故事    传递有态度的思想 2020年9月20日12时至17时,第六届中国大学生程序设计竞赛网络赛预选赛在杭州电子科技大学OJ成功举办,黑龙江外国 ...

  3. 秦皇岛计算机编程大赛,南科大学子在第六届中国大学生程序设计竞赛(秦皇岛)获多个奖项...

    2020年10月18日,第六届中国大学生程序设计竞赛(China Collegiate Programming Contest,简称CCPC)(秦皇岛)暨2020中国大学生程序设计竞赛女生专场在秦皇岛 ...

  4. 第六届河南省大学生程序设计竞赛—— 外星人的供给站 (贪心)

    710-外星人的供给站 内存限制:64MB 时间限制:1000ms 特判: No 题目描述: 外星人指的是地球以外的智慧生命.外星人长的是不是与地球上的人一样并不重要,但起码应该符合我们目前对生命基本 ...

  5. 2014 年第六届全国大学生数学竞赛江西赛区赣南师范学院获奖名单(数学专业)

    2014 年第六届全国大学生数学竞赛江西赛区赣南师范学院获奖名单(数学专业) 姓名 性别 学校 所学专业 类别 获奖等级 李秀芹 女 赣南师范学院 数学与应用数学 数学专业 一等奖 杨启明 男 赣南师 ...

  6. 徐佳计算机教授,计算机与软件学院第六届ECNU Coder程序设计竞赛成功举办

    计算机科学与软件工程学院第六届ECNU Coder程序设计竞赛暨ACM选拔赛及软件实践能力测评于12月16日下午13点30分,在计算中心和理科楼的机房火热举行.2015级软件工程全体新生.部分计算机系 ...

  7. 赛宁首创革新赛制助力人才培养 | 第十六届全国大学生信息安全竞赛-创新实践能力赛全面启动!

    ​​为积极响应国家网络空间安全人才战略,加快攻防兼备创新人才培养步伐,实现以赛促学.以赛促教.以赛促用,推动网络空间安全人才培养和产学研用生态发展,由国防科技大学与中国科学技术大学联合承办的第十六届全 ...

  8. FZU Problem 2221 RunningMan(贪心)

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

  9. 第 2 届河北省大学生程序设计竞赛(河北省赛)-Problem G. 520-题解

    传送门 Problem A. Mex Query Problem B. Nim Game Problem C. icebound 的账单 Problem G. 520 Problem H. 神殿 Pr ...

最新文章

  1. php中post,php中post的用法是什么
  2. Spring MVC页面重定向
  3. 重写数组的方法(改变原数组)
  4. android usb弹窗权限r,Android USB权限对话框永远不会出现
  5. python解释器用什么写的_用 Python 从零开始写一个简单的解释器(3)
  6. 如何进行Java EE性能测试与调优
  7. 模块一 day06 数据类型(中)
  8. A survey of network-based intrusion detection data sets翻译二(5-8)
  9. DataWhale组队学习——DCIC赛事 task1
  10. 电脑设置U盘启动快捷键
  11. 测试面试题-如何测试朋友圈
  12. Lazada跨境直播,双11直播成绩傲娇!如何做到大促流量销量双收割?
  13. 怎样黑进Microsoft:循序渐进指南 (转)
  14. Java中Object类
  15. 数据库拆分:横向拆分和纵向拆分
  16. 使用SqlConnection.connectionString连接数据库
  17. 计算CP、CR、CF1、OP、OR、OF1和mAP的top-3评价指标
  18. 交行信用卡总经理王卫东:信用卡互联网转型有五大基础
  19. 软科2018大学计算机,2018中国大学排名新发:软科2018中国大学排名结果
  20. sonar java 编译_Sonar编译问题对应:File [...] can't be indexed twice.

热门文章

  1. 微信小程序----switch组件(开关选择器)
  2. 蚁群算法求解TSP问题(Python实现)
  3. F103固件库Keil工程自动拷贝
  4. 求助(关于FT2232驱动的问题)
  5. HCIA-南航金城-20211204
  6. 每天一个设计模式之 -- 装饰器模式
  7. 标记肽Bz-Pro-Phe-Arg-pNA、59188-28-2
  8. FineReport和泛微OA(Ecology)的单点登录集成方案
  9. 学习记录:python列表字典嵌套
  10. 关于食品企业的健康发展,重视品牌概念是关键