UESTC 1034 AC Milan VS Juventus 分情况讨论

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 20032003 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 aa:bb 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 55 turns,
    in each turn, 22 teams
    each should take a penalty shoot. If goal, the team get 11 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 55 turns
    the 22 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!

时间: 2024-10-07 11:12:45

UESTC 1034 AC Milan VS Juventus 分情况讨论的相关文章

AC Milan VS Juventus(模拟)

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 20032003 between AC Milan and Juventus f

acd the cover circle(分情况讨论)

Problem Description 用半径相等的两个圆覆盖一个w*h的矩形,要求两圆不相交且必须在矩形内.求覆盖面积最大时两圆半径. Input 输入包含多组数据,EOF结束. 每组数据包含一行,分别是两个实数w和h代表矩形的长和宽. 0<w,h<10000 Output 每组数据输出一行表示圆的半径,小数点后保留三位. Sample Input 2.000 1.000 Sample Output 0.500 (前提w>=h)当W>=2*h时,r=h/2; 当w<2*h时

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

要点 不难想到gcd一下然后枚举每个开头走一圈,并记录一下数值. 最终答案是分情况的:1.能走几圈走几圈然后加上最后剩余的最大子段和:2.也可能是最后一圈后面的拖后腿了,所以最后一圈没走完就停,即长度为一圈长的最大子段和:3.一圈为负数时只考虑一圈内的即可,多走了反而变差. 求环形的.不超过某长度的最大子段和,用双端队列处理一下前缀和. const int maxn = 1e4 + 5; int T, n, m, k; ll s, a[maxn]; ll calc(vector<ll> v,

HDU 2577 分情况多维DP

How to Type Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 6787    Accepted Submission(s): 3057 Problem Description Pirates have finished developing the typing software. He called Cathy to test

CODE FESTIVAL 2017 qual A--C - Palindromic Matrix(模拟所有情况,注意细节)

个人心得:其实本来这题是有规律的不过当时已经将整个模拟过程都构思出来了,就打算试试,将每个字符和总和用优先队列 装起来,然后枚举每个点,同时进行位置标志,此时需要多少个点的时候拿出最大的和出来,若不满足就输出No,结果一直卡在三组 数据.比赛完后一想,优先队列虽然用处大,不过当行列存在奇数的时候此时只要2个就可以,而如果你从最大的4个中拿出来, 那么下一层循环中必然有一个位置无法填充,如此就导致了算法的失败.所以后面建立个奇偶判定就好了. 感悟: 多注意思考和细节,从不同的层次看待问题,既可以全

周赛题

UESTC - 1034 AC Milan VS Juventus Time Limit: 1000MS   Memory Limit: 65535KB   64bit IO Format: %lld & %llu SubmitStatus Description Kennethsnow and Hlwt both love football. One day, Kennethsnow wants to review the match in 2003 between AC Milan and

CodeVS3958 火车进站

3958 火车进站 时间限制: 1 s 空间限制: 256000 KB 题目等级 : 大师 Master 题目描述 Description 火车站内往往设有一些主干线分叉出去的铁路支路,供火车停靠,以便上下客或装载货物.铁路支路有一定长度:火车也有一定的长度,且每列火车的长度相等. 假 设某东西向的铁路上,有一小站.该站只有一条铁路支路可供火车停靠,并且该铁路支路最多能容纳M 辆火车.为了火车行驶的通畅,该站只允许火车自东方进站,自西方出站,且先进站的火车必须先出站,否则,站内火车将发生堵塞.该

到天宫做客-最后一分钟AC!!!

问题 C: 到天宫做客 时间限制: 1 Sec  内存限制: 128 MB提交: 100  解决: 26[提交][状态][讨论版] 题目描述 有一天,我做了个梦,梦见我很荣幸的接到了猪八戒的邀请,到天宫陪他吃酒.我犹豫了.天上一日,人间一年啊!当然,我是个闲人,一年之中也没有多少时日是必须在人间的,因此,我希望选一个最长的空闲时间段,使我在天上待的时间尽量长.记住,今年是4000年.天上一天也是24小时,每小时60分,每分60秒. 输入 第一行是一个非负整数 N,表示4000年中必须呆在人间的天

联通子数组最大值设计03

So郁闷,我先把老师提出的问题写出来; 返回一个二维整数数组中最大联通子数组的和. 要求: 输入一个二维整形数组,数组里有正数也有负数. 求所有子数组的和的最大值.下面是给的示例图: 最近已经完全的陷入了编程的怪圈,自己完全没找到自己的方向吧,废话不多说,直接上问题:在子数组问题上我觉得基本都是一位子数组的变形,应该不会有特别的变化,最多是难度上去,但是基本的思想不会变,今天我发现错了,可能是我错了. 我的想法:在网上看代码找到的灵感:因为觉得老师上课讲的图的方法有些麻烦所以就想还是用一维数组的