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 ...
随机推荐
- 队列queue的一些操作
1. q = queue.Queue(5) 实例化,5为队列长度 2. q.put("haha") 将数据加入队列,计数器+1 3. q.get() 取出数据,计数器不变 4. q ...
- 记录初学者学习Hive时踩过的坑
1. 缺少MySQL驱动包 1.1 问题描述 Caused by: org.datanucleus.store.rdbms.connectionpool.DatastoreDriverNotFound ...
- iOS app启动流程
最近看了些Runtime Runloop的一些知识.边看边摸索.看到群里有人在问 一些面试题.其中就提到了app的启动流程. 所以这里也研究小结一下,以供自己学习备用. 1.项目要运行,就要有入口. ...
- ctf study of jarvisoj reverse
[61dctf] androideasy 164求解器 50 相反 脚本如下: s='' a=113, 123, 118, 112, 108, 94, 99, 72, 38, 68, 72, 87, ...
- codeforces148----E. Porcelain
#include <iostream> #include <cstring> using namespace std; ; int s[maxn];//s[i]表示每行前i个数 ...
- [SNV]奇怪的错误搜集
ld: library not found for -XXXXX clang: error: linker command failed with exit code 1 (use -v to see ...
- Redis自学笔记:1.简介
博主教材:李子骅.人民邮电出版社.<redis入门指南> 博主操作系统系统:虚拟机Ubuntu16.04 博主redis版本:3.0.6 第1章:简介 redis是一个开源的.高性能的.基 ...
- 2、SQL UNION 和 UNION ALL 操作符
网址:http://www.w3school.com.cn/sql/sql_union.asp SQL UNION 操作符 UNION 操作符用于合并两个或多个 SELECT 语句的结果集. 请注意, ...
- 备份LeetCode OJ自己编写的代码
常泡LC的朋友知道LC是不提供代码打包下载的,不像一般的OJ,可是我不备份代码就感觉不舒服- 其实我想说的是- 我自己写了抓取个人提交代码的小工具,放在GitCafe上了- 不知道大家有没有兴趣 ht ...
- React Native使用init新建项目出现异常
情况说明 最近在使用使用react-native init之后没有生成app.js, index.js等文件,缺少了很多文件,如图: 原因 因为近期rn更新,某些东西不适配,然后暂时能找到的方法就是指 ...