当前位置:网站首页>PTA 1046 stroke (15 points)

PTA 1046 stroke (15 points)

2022-06-24 05:10:00 freesan44

subject

Boxing is an interesting part of the ancient Chinese wine culture . The method of two people on the wine table is : Shout out a number from each mouth , Draw a number with your hand . If someone's number is exactly equal to the sum of the two Numbers , Whoever wins , The loser gets a glass of wine . Either a win or a loss goes on to the next round , Until the only winner comes along .

So let's give you a 、 The record of two people's rowing , Please count how many glasses of wine they drank at last .

Input format :

Enter the first line to give a positive integer first N(≤100), And then N That's ok , Each line gives a record of one stroke , The format is :

A shout A stroke Ethyl shout B row

Among them, shouting is the number , A stroke is a number drawn out , No more than 100 The positive integer ( Row with both hands ).

Output format :

Output a in a row 、 B. the number of glasses they drink , Separated by a space .

 sample input :
5
8 10 9 12
5 10 5 10
3 8 5 12
12 18 1 13
4 16 12 15
 No blank lines at the end 
 sample output :
1 2
 No blank lines at the end 

Their thinking

inputRound = int(input())
# inputRound = 5
aWin = 0
bWin = 0
for i in range(inputRound):
    aH,aNum,bH,bNum = map(int, input().split())
    # aH, aNum, bH, bNum = map(int, "3 8 5 12".split())
    if aNum != bNum:
        if aNum == (aH + bH):
            aWin += 1
        elif bNum == (aH + bH):
            bWin += 1
print(str(bWin)+ " " + str(aWin))
原网站

版权声明
本文为[freesan44]所创,转载请带上原文链接,感谢
https://yzsam.com/2021/08/20210822001429496c.html