UESTC 1034 AC Milan VS Juventus 分情况讨论
AC Milan VS Juventus
Time Limit: 3000/1000MS (Java/Others) Memory Limit: 65535/65535KB (Java/Others)
Status
Kennethsnow and Hlwt both
love football.
One day, Kennethsnow wants
to review the match in 2003 between
AC Milan and Juventus for the Championship Cup. But before the
penalty shootout. he fell asleep.
The next day, he asked Hlwt for
the result. Hlwt said that it scored a:b in
the penalty shootout.
Kennethsnow had some doubt
about what Hlwt said because Hlwt is
a fan of Juventus but Kennethsnow loves AC Milan.
So he wanted to know whether the result can be a legal result of a penalty shootout. If it can be, output Yes,
otherwise output No.
The rule of penalty shootout is as follows:
There will be 5 turns,
in each turn, 2 teams
each should take a penalty shoot. If goal, the team get 1 point.
After each shoot, if thewinner can be confirmed(i.e: no matter what happened after this shoot, the winner will not change), the match end immediately.
If after 5 turns
the 2 teams
score the same point. A new turn will be added, until that one team get a point and the other not in a turn.
Before the penalty shootout begins, the chief referee will decide which team will take the shoot first, and afterwards, two teams will take shoot
one after the other. Since Kennethsnow fell asleep last night, he had no idea whether AC Milan or Juventus took the first shoot.
Input
The only line contains 2 integers a, b.
Means the result that Hlwt said.
0≤a,b≤10
Output
Output a string Yes or No,
means whether the result is legal.
Sample input and output
| Sample Input | Sample Output |
|---|---|
3 2 |
Yes |
2 5 |
No |
Hint
The Sample 1 is
the actual result of the match in 2003.
The Sample 2,
when it is 2:4 after 4 turns,
AC Milan can score at most 1point
in the next turn. So Juventus has win when it is 2:4.
So the result cannot be 22:55.
This story happened in a parallel universe. In this world where we live, kennethsnow is
a fan of Real Madrid.
Source
My Solution
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std; int main()
{
int a, b;
scanf("%d%d", &a, &b);
if(a == b )printf("No");
else if((a == 5 && b <5) || (b == 5&& a <5)) {if(abs(a-b) >= 3) printf("No");else printf("Yes"); } //!!
else if(a < 5 && b <5) {if(abs(a-b) >= 4) printf("No");else printf("Yes"); }
else {if(abs(a-b) > 1) printf("No");else printf("Yes"); }
return 0;
}
Thank you all!
UESTC 1034 AC Milan VS Juventus 分情况讨论的更多相关文章
- cdoj第13th校赛初赛A - AC Milan VS Juventus 【枚举】
http://acm.uestc.edu.cn/#/contest/show/54 A - AC Milan VS Juventus Time Limit: 3000/1000MS (Java/Oth ...
- AC Milan VS Juventus(模拟)
AC Milan VS Juventus Time Limit: 3000/1000MS (Java/Others) Memory Limit: 65535/65535KB (Java/Oth ...
- HNU 12833 Omar’s Bug(分情况讨论)
题目链接:http://acm.hnu.cn/online/?action=problem&type=show&id=12833&courseid=268 解题报告:有个11个 ...
- bzoj 1067 分情况讨论
这道题考察人的严谨,各种情况分类讨论. #include <cstdio> #include <algorithm> #include <map> #define ...
- Valid Number——分情况讨论最经典的题(没细看)——这题必须静下心来好好看看
Validate if a given string is numeric. Some examples: "0" => true " 0.1 " =&g ...
- bzoj2756: [SCOI2012]奇怪的游戏(网络流+分情况)
2756: [SCOI2012]奇怪的游戏 题目:传送门 题解: 发现做不出来的大难题一点一个网络流 %大佬 首先黑白染色(原来是套路...)染色之后就可以保证每次操作都一定会使黑白各一个各自的值加1 ...
- HDU6444(子段和、分情况比较)
要点 不难想到gcd一下然后枚举每个开头走一圈,并记录一下数值. 最终答案是分情况的:1.能走几圈走几圈然后加上最后剩余的最大子段和:2.也可能是最后一圈后面的拖后腿了,所以最后一圈没走完就停,即长度 ...
- CONTINUE...?模拟分情况
CONTINUE...? DreamGrid has classmates numbered from to . Some of them are boys and the others are ...
- HDU 2577 分情况多维DP
How to Type Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total ...
随机推荐
- LeetCode竞赛题:笨阶乘(我们设计了一个笨阶乘 clumsy:在整数的递减序列中,我们以一个固定顺序的操作符序列来依次替换原有的乘法操作符:乘法(*),除法(/),加法(+)和减法(-)。)
通常,正整数 n 的阶乘是所有小于或等于 n 的正整数的乘积.例如,factorial(10) = 10 * 9 * 8 * 7 * 6 * 5 * 4 * 3 * 2 * 1.相反,我们设计了一个笨 ...
- OpenJ_Bailian 2814 拨钟问题
总时间限制: 1000ms 内存限制: 65536kB 描述 有9个时钟,排成一个3*3的矩阵. |-------| |-------| |-------|| | | | | | ||---O | ...
- Jenkins部署码云SpringBoot项目
本文介绍jenkins如何从gitee上clone项目,然后使用maven打包并后台启动. 1.Jenkins介绍 Jenkins是一个开源软件项目,是基于Java开发的一种持续集成工具,用于监控持续 ...
- ISP PIPLINE (一) BLC 以及 线性化
what is the BlackLevel? 暗电流来源1.raw8为例,单个pixel的有效值是0~255,但是实际AD芯片的精度可能无法将电压值很小的一部分转换出来,芯片厂会刻意添加一个固定的偏 ...
- 在eclipse中配置Python环境
1.下载pydev https://sourceforge.net/projects/pydev/files/pydev/PyDev%202.2.2/ 2.解压pydev插件后 有features.p ...
- 【整理】Java 9新特性总结
距Java 8正式发布三年多时间,Java 9 于2017年9月21日正式发布, 你可能已经听说过 Java 9 的模块系统(讨论的最多的),但是这个新版本还有许多其它的更新. 这里我整理了Java ...
- Java并发编程(六)-- 同步块
上一节已经讲到,使用Synchronzied代码块可以解决共享对象的竞争问题,其实还有其他的方法也可以避免资源竞争问题,我统称他们为Java同步块.Java 同步块(synchronized bloc ...
- Shell脚本笔记(九)数组
数组 一)定义 #最常用:小括号加空格: a=( ) #键值对形式: b=([]=x []=men []=z) #定义变量的形式 c[]=; c[]=; c[]= #命令结果作为数组元素 d=($(c ...
- 数据库——MongoDB的安装
1.进入到 /usr/local/ 目录: 1 cd /usr/local 2.安装必要插件 yum -y install gcc make gcc-c++ openssl-devel wget yu ...
- hihoCoder 1143 : 骨牌覆盖问题·一(递推,矩阵快速幂)
[题目链接]:click here~~ 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 骨牌,一种古老的玩具.今天我们要研究的是骨牌的覆盖问题: 我们有一个2xN的长条形 ...