[파이썬/Python] 백준 24736번 Football Scoring
[파이썬/Python] 백준 24736번 Football Scoring
https://www.acmicpc.net/problem/24736
24736번: Football Scoring
There are two lines of input each containing five space-separated non-negative integers, T, F, S, P and C representing the number of Touchdowns, Field goals, Safeties, Points-after-touchdown and two-point Conversions after touchdown respectively. (0 ≤ T
www.acmicpc.net
문제
There are five ways to score points in american professional football:
- Touchdown - 6 points
- Field Goal - 3 points
- Safety - 2 points
- After touchdown
- 1 point (Field Goal or Safety) - Typically called the “Point after”
- 2 points (touchdown) - Typically called the “Two-point conversion”
(https://operations.nfl.com/the-rules/nfl-video-rulebook/scoring-plays/)
Given the box score values for two competing teams, calculate the point total for each team.
해설
T, F, S, P, C 가 input 으로 주어지면,
T는 6점, F는 3점, S는 2점, P는 1점, C는 2점으로 총점을 계산해서
홈팀과 어웨이팀의 총 점수를 구해주면 된다.
코드
for _ in range(2):
score = 0
T, F, S, P, C = map(int, input().split())
score = T*6 + F*3 + S*2 + P*1 + C*2
print(score, end=" ")
풀이
1. 홈팀과 어웨이팀의 점수를 받아줄 score 를 0으로 초기화한다.
score = 0
2. T, F, S, P, C 를 입력 받는다.
T, F, S, P, C = map(int, input().split())
3. 각 입력 값에 해당하는 점수를 곱하여 총 점수를 계산한다.
score = T*6 + F*3 + S*2 + P*1 + C*2
4. 구해준 점수를 출력한다. 이 때, 같은 줄에 공백으로 구분하여 출력해야 하므로 end=" " 속성을 추가한다.
print(score, end=" ")
5. 1~4 과정을 두번 반복하여 수행한다. (홈팀, 어웨이팀 총 2회)
for _ in range(2):
score = 0
T, F, S, P, C = map(int, input().split())
score = T*6 + F*3 + S*2 + P*1 + C*2
print(score, end=" ")
