【思维】Iranian ChamPions Cup

版权声明:版权声明:本文为博主原创文章,转载请注明出处。 https://blog.csdn.net/YT201758501112/article/details/89202537

题目描述

The Iranian ChamPions Cup (ICPC), the most prestigious football league in Iran, is reaching its end, and people are eagerly waiting for the finals, which happened to be between the two most popular Iranian teams, Persepolis and Esteghlal.
The ICPC finals consist of two matches, with each team competing as the home team in one match. The winning team is determined by aggregate score, the sum of the scores of the two matches. For example, if the scores of the two matches
are Persepolis 6–0 Esteghlal in the first match, and Esteghlal 3–1 Persepolis in the second match, then the aggregate score will be Persepolis 7–3 Esteghlal, meaning that Persepolis is the winner. If aggregates are equal, the away goals rule is used to determine the winner, in which case the winner is the team that scored the most goals in the match it played away from home. If the result is still equal, a penalty shootout is required.
Hana, an avid football fan, is trying to figure out various scenarios in which her favorite team wins the finals. To this end, she aims to write a program that gets as input the number of goals in the two matches, and decides which team is the winner if it can be derived from the aggregate scores and the away goals rule, otherwise declares that the match goes to penalty kicks. You are going to help Hana write such a program.

输入

The first line of the input contains two space-separated integers p1 and s1 , where p1 and s1 are the number of goals scored by Persepolis and Esteghlal, respectively, in the first match in which Persepolis is the home team. The second line contains two space-separated integers s2 and p2 , where s2 and p2 are the number of goals scored by Esteghlal and Persepolis, respectively, in the second match in which Esteghlal is the home team. All input integers are between 0 and 20, inclusively.

输出

In the output, print the name of the winning team, either Persepolis or Esteghlal, if the winner can be determined by the aggregate scores and the away goals rule. Otherwise, print Penalty.

样例输入

复制样例数据

3 0
2 1

样例输出

Persepolis

题目大意:

第一行输入两个整数,代表以 Persepolis 为主场时 Persepolis 与 Esteghlal的比分,假如为6:0,而第二行则是以Esteghlal为主场Esteghlal与 Persepolis的比分,假如为2:1,则可以看出最终比分 Persepolis:Esteghlal为7:2,此时 Persepolis 获胜,若两队的比分相同,则按照客场规则,客场进球多的队伍获胜,若仍相同,则需进行点球大赛,输出Penalty。

解题思路:

看懂题意后其实十分简单,进行简单的比较判断即可。

代码:

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <bitset>
#include <set>
#include <utility>
#include <sstream>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define inf 0x3f3f3f3f
#define rep(i,l,r) for(int i=l;i<=r;i++)
#define lep(i,l,r) for(int i=l;i>=r;i--)
#define ms(arr) memset(arr,0,sizeof(arr))
//priority_queue<int,vector<int> ,greater<int> >q;
const int maxn = (int)1e5 + 5;
const ll mod = 1e9+7;
int main() 
{
    #ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    #endif
    //freopen("out.txt", "w", stdout);
    ios::sync_with_stdio(0),cin.tie(0);
    int a1,b1,a2,b2;
    cin>>a1>>b1>>a2>>b2;
    int t1=a1+b2;
    int t2=a2+b1;
    if(t1>t2) cout<<"Persepolis"<<endl;
    else if(t1<t2) cout<<"Esteghlal"<<endl;
    else {
    	if(b1<b2) cout<<"Persepolis"<<endl;
    	else if(b1>b2) cout<<"Esteghlal"<<endl;
    	else cout<<"Penalty"<<endl;
    }
    return 0;
}

猜你喜欢

转载自blog.csdn.net/YT201758501112/article/details/89202537
CUP