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 22 integers aa, bb. Means the result that Hlwt said.

0a,b100≤a,b≤10

Output

Output a string Yes or No, means whether the result is legal.

Sample input and output

Sample InputSample Output
3 2
Yes
2 5
No

Hint

The Sample 11 is the actual result of the match in 20032003.

The Sample 22, when it is 22:44 after 44 turns, AC Milan can score at most 11 point in the next turn. So Juventus has win when it is 22:44. 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.

题解:两个队投球,进了得1分,当一个队必胜的时候可以不用打了;现在给出得分判断是否合理;

代码:

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
bool work(int a, int b){
    if(a == b)
        return false;
    if(a > 5 || b > 5){
        if(abs(a - b) == 1)
            return true;
        else
            return false;
    }
    if(a == 5 || b == 5){
        if(b < 3 || a < 3)
            return false;
        else
            return true;
    }
    if(a == 4 || b == 4){
        if(a == 0 || b == 0)
            return false;
        else
            return true;
    }
    if(a == 3 || b == 3){
        return true;
    }
    return true;
}
int main(){
    int a, b;
    while(~scanf("%d%d", &a, &b)){
        if(work(a, b))
            puts("Yes");
        else
            puts("No");
    }
    return 0;
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值