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/Others) Memory Limit: 65535/65535KB (Java/Others)
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 1 point in the next turn. So Juventus has win when it is 2:4. So the result cannot be 2:5.
This story happened in a parallel universe. In this world where we live, kennethsnow
is a fan of Real Madrid.
思路:最简单也最不容易出错的情况就是把特殊情况都枚举出来。
官方题解:
代码:
1 #include <fstream> 2 #include <iostream> 3 #include <algorithm> 4 #include <cstdio> 5 #include <cstring> 6 #include <cmath> 7 #include <cstdlib> 8 #include <vector> 9 10 using namespace std; 11 12 #define PI acos(-1.0) 13 #define EPS 1e-10 14 #define lll __int64 15 #define ll long long 16 #define INF 0x7fffffff 17 18 19 20 int main(){ 21 //freopen("D:\\input.in","r",stdin); 22 //freopen("D:\\output.out","w",stdout); 23 int a,b; 24 scanf("%d %d",&a,&b); 25 if(a>b){ 26 int t=a; 27 a=b; 28 b=t; 29 } 30 if(a==b) {puts("No");return 0;} 31 if(b<=5){ 32 if(a==0&&b==4) {puts("No");return 0;} 33 if(a==0&&b==5) {puts("No");return 0;} 34 if(a==1&&b==5) {puts("No");return 0;} 35 if(a==2&&b==5) {puts("No");return 0;} 36 else {puts("Yes");return 0;} 37 }else{ 38 if(b-a>1) {puts("No");return 0;} 39 else {puts("Yes");return 0;} 40 } 41 return 0; 42 }
相关文章
- 【VS开发】【视频开发】利用ffmpeg+opencv实现画中画
- 【VS开发】【图像处理】GigE和USB3 vision选择?
- 【VS开发】【电子电路技术】VPX技术介绍
- 【VS开发】CTimeSpan类
- 【VS开发】VS2010中导入ActiveX控件
- 【VS开发】四大图像库:OpenCV/FreeImage/CImg/CxImage
- # asio run vs poll
- 概念:dependency injection, IOC, vs callback
- 9月11日科技资讯|Mate 30 不预装任何谷歌应用;阿里巴巴发布新“六脉神剑”;VS Code 1.38 发布
- [Django] 21 - DRF: APIView vs Viewsets
- 解析:智能沙盒vs.传统沙盒
- VS 2017与 Docker
- EEPlat PaaS VS Saleforce force.com
- 【云栖大会】 中国杭州vs.美国硅谷,今年的云栖大会有一场连续48小时的编程大赛
- CAD二次开发--CAD2007(.Net3.5环境)等低版本CAD二次开发在VS中无法捕获断点调试解决办法(CAD二次开发无法断点调试解决办法)