Gym 101778I

題目鏈接

https://vjudge.net/problem/Gym-101778I

題意

兩個隊伍比賽,第一場在一隊主場,第二場在二隊主場,兩場比賽總得分多的隊伍獲勝。如果一樣,則在對方主場得分多的球隊獲勝。如果一樣,則無法判斷,要進行加時賽。

輸入a,b,c,d,分別表示第一場一隊二隊得分,第二場一隊二隊得分。

輸出獲勝的隊伍。一隊獲勝輸出1,二隊獲勝輸出2,無法判斷輸出-1。

思路

if-else即可。

AC代碼
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<set>
#include<string>
#include<sstream>
#include<cctype>
#include<map>
#include<stack>
#include<queue>
#include<list>
#include<cstdlib>
#include<ctime>
using namespace std;
#define INF 0x3f3f3f3f
typedef long long ll;

int main()
{
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    int T, a, b, c, d;
    scanf("%d", &T);
    while (T--)
    {
        scanf("%d%d%d%d", &a, &b, &c, &d);
        if(a + c > b + d)
        {
            printf("1\n");
        }
        else if(a + c < b + d)
        {
            printf("2\n");
        }
        else if(c > b)
        {
            printf("1\n");
        }
        else if(c < b)
        {
            printf("2\n");
        }
        else
        {
            printf("-1\n");
        }
    }
    return 0;    
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章