[백준/파이썬] 15340번 풀이
업데이트:
문제 정보
- 문제 출처: 백준 온라인 저지
- 문제 링크: 15340번 문제
- 문제풀이 코드 GitHub 링크
- 제출 언어: Python 3
풀이
문제
There are three mobile operators in Iran. Each operator has different prices for call and data usage, given in the table below. All prices are in Rials:
# Name Call (per minute) Data (per megabyte)
1 ParsTel 30 40
2 ParsCell 35 30
3 ParsPhone 40 20
Some foreign students have arrived Iran to participate in the ACM-ICPC, Tehran Site. They already know how many minutes they will call, and how much Internet they will use. For each student, you want to recommend an operator to minimize the total cost of call usage and data usage for that student.
입력 요약
Each line of the input contains the information of one student. For each student, there are two positive integers c and d (1 ≤ c, d ≤ 1000) that show the amount of call (in minutes) and data usage (in megabytes) for the student, respectively. …
출력 요약
For each student, print a line containing the minimum total cost of call usage and data usage.
코드
l=[[30,40],[35,30],[40,20]]
while True:
a,b=map(int,input().split())
if a==b==0:break
print(min([i[0]*a+i[1]*b for i in l]))
설명
핵심은 구현 관점에서 There are three mobile operators in Iran. Each operator has different prices for call and data usage, given in the table below. …를 만족하도록 로직을 구성하는 것입니다.
코드는 입력을 파싱한 뒤 조건 분기와 계산을 순서대로 수행하고, 문제에서 요구한 형식으로 결과를 출력합니다.
경계값과 예외 케이스도 함께 고려해 오답이 나기 쉬운 상황을 방지합니다.
댓글남기기