UESTC - 1034 AC Milan VS Juventus (模拟&博弈)

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

0a,b10

Output

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

Sample Input

3 2

2 5

Sample Output

Yes

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.

Source

The 13th UESTC Programming Contest Preliminary
//题意:输入a,b;
表示两个人在点球,a,b表示两个人的得分数
现在要求:
进行五局的比赛,没进一个球的一分,没进不得分,如果比赛已经分出胜负了,那么比赛就结束,后面的几轮就不用比了,现在问给定的a,b是否是正确。
//思路:
因为是问是否确定所以要逐个球比较。
#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;
}

你可能感兴趣的:(UESTC - 1034 AC Milan VS Juventus (模拟&博弈))