AC Milan VS Juventus

Time Limit: 3000/1000MS (Java/Others)     Memory Limit: 65535/65535KB (Java/Others)
Submit 
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 the

  • winner 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

The 13th UESTC Programming Contest Preliminary
The question is from here.

My Solution

分情况讨论清楚就好。然后注意 a == b 的时候也是No
把分类出来的区间理清楚。不要条件里面混杂着不该包括的东西

#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 分情况讨论的更多相关文章

  1. 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 ...

  2. AC Milan VS Juventus(模拟)

    AC Milan VS Juventus Time Limit: 3000/1000MS (Java/Others)     Memory Limit: 65535/65535KB (Java/Oth ...

  3. HNU 12833 Omar’s Bug(分情况讨论)

    题目链接:http://acm.hnu.cn/online/?action=problem&type=show&id=12833&courseid=268 解题报告:有个11个 ...

  4. bzoj 1067 分情况讨论

    这道题考察人的严谨,各种情况分类讨论. #include <cstdio> #include <algorithm> #include <map> #define ...

  5. Valid Number——分情况讨论最经典的题(没细看)——这题必须静下心来好好看看

    Validate if a given string is numeric. Some examples: "0" => true " 0.1 " =&g ...

  6. bzoj2756: [SCOI2012]奇怪的游戏(网络流+分情况)

    2756: [SCOI2012]奇怪的游戏 题目:传送门 题解: 发现做不出来的大难题一点一个网络流 %大佬 首先黑白染色(原来是套路...)染色之后就可以保证每次操作都一定会使黑白各一个各自的值加1 ...

  7. HDU6444(子段和、分情况比较)

    要点 不难想到gcd一下然后枚举每个开头走一圈,并记录一下数值. 最终答案是分情况的:1.能走几圈走几圈然后加上最后剩余的最大子段和:2.也可能是最后一圈后面的拖后腿了,所以最后一圈没走完就停,即长度 ...

  8. CONTINUE...?模拟分情况

    CONTINUE...? DreamGrid has  classmates numbered from  to . Some of them are boys and the others are ...

  9. HDU 2577 分情况多维DP

    How to Type Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total ...

随机推荐

  1. 019 python面相对象编程

    一:self的意思 1.说明 self代表类的实例,而非类. 类的方法与普通的函数只有一个特别的区别——它们必须有一个额外的第一个参数名称, 按照惯例它的名称是 self. self 代表的是类的实例 ...

  2. PAT (Basic Level) Practise - 成绩排名

    1004. 成绩排名 题目链接:https://www.patest.cn/contests/pat-b-practise/1004 读入n名学生的姓名.学号.成绩,分别输出成绩最高和成绩最低学生的姓 ...

  3. java中path和CLASSPATH的配置和意义解析

    原文链接 https://blog.csdn.net/eclipse_yin/article/details/51447169 一.JDK的安装和基本配置 JDK的安装: 1) 如果想要获得JDK,那 ...

  4. POJ 1284 Primitive Roots (欧拉函数+原根)

    <题目链接> 题目大意: 满足{ ( $x^{i}$ mod p) | 1 <=$i$ <= p-1 } == { 1, …, p-1 }的x称为模p的原根.给出p,求原根个数 ...

  5. HDU 2586 How far away ?(经典)(RMQ + 在线ST+ Tarjan离线) 【LCA】

    <题目链接> 题目大意:给你一棵带有边权的树,然后进行q次查询,每次查询输出指定两个节点之间的距离. 解题分析:本题有多重解决方法,首先,可用最短路轻易求解.若只用LCA解决本题,也有三种 ...

  6. SpringBoot邮件发送

    这篇文章介绍springboot的邮件发送. 由于很简单就没有分出server和imp之类,只是在controller简单写个方法进行测试. 首先pom文件加入spring-boot-starter- ...

  7. Xamarin Essentials教程使用加速度传感器Accelerometer

    Xamarin Essentials教程使用加速度传感器Accelerometer   加速度传感器是一种能够测量加速度的传感器,用于检测设备状态的改变.在Xamarin中,如果开发者想要使用加速度传 ...

  8. Apache自带压力测试工具----linux环境中ab命令简介及结果分析

    ab(apache bench)是apache下的一个工具,主要用于对web站点做压力测试, 基础用法: 其中-c选项为一次发送的请求数量,及并发量.-n选项为请求次数. 实验测试: [dev@web ...

  9. mongoose 根据_id更新数据

    let photoId = mongoose.Types.ObjectId(`${virtual.productId[0]}`) await model.photo.findByIdAndUpdate ...

  10. Linux引导程序类型

    Bootloader Monitor 描述 X86 ARM PowerPC LILO 否 Linux磁盘引导程序 是 否 否 GRUB 否 GNU的LILO替代程序 是 否 否 Loadlim 否 从 ...