[백준/파이썬] 17009번 풀이
업데이트:
문제 정보
- 문제 출처: 백준 온라인 저지
- 문제 링크: 17009번 문제
- 문제풀이 코드 GitHub 링크
- 제출 언어: Python 3
풀이
문제
You record all of the scoring activity at a basketball game. Points are scored by a 3-point shot, a 2-point field goal, or a 1-point free throw.
You know the number of each of these types of scoring for the two teams: the Apples and the Bananas. Your job is to determine which team won, or if the game ended in a tie.
입력 요약
The first three lines of input describe the scoring of the Apples, and the next three lines of input describe the scoring of the Bananas. …
출력 요약
The output will be a single character. If the Apples scored more points than the Bananas, output ‘A’. If the Bananas scored more points than the Apples, output ‘B’. Otherwise, output ‘T’, to indicate a tie.
코드
a,b=sum([int(input())*(3-i) for i in range(3)]),sum([int(input())*(3-i) for i in range(3)])
if a>b:
print("A")
elif a<b:
print("B")
else:
print("T")
설명
핵심은 구현 관점에서 You record all of the scoring activity at a basketball game. Points are scored by a 3-point shot, a 2-point field goal, or a 1-point free throw. …를 만족하도록 로직을 구성하는 것입니다.
코드는 입력을 파싱한 뒤 조건 분기와 계산을 순서대로 수행하고, 문제에서 요구한 형식으로 결과를 출력합니다.
경계값과 예외 케이스도 함께 고려해 오답이 나기 쉬운 상황을 방지합니다.
댓글남기기