[백준/파이썬] 14004번 풀이
업데이트:
문제 정보
- 문제 출처: 백준 온라인 저지
- 문제 링크: 14004번 문제
- 문제풀이 코드 GitHub 링크
- 제출 언어: Python 3
풀이
문제
“I once met an interesting guy who had a phone with two batteries.” - Dudu, 2014
Dudu once met an interesting chap who had a phone with two batteries. With that in mind he decided to create a phone that would have a pair of batteries for his upcoming trip to Thailand.
His company, Interesting Chap Phone Charging (ICPC), created an advanced dual battery technology. …
입력 요약
The input will consist of 4 integers A, B, C and D. They are respectively the rate a phone uses energy in Amperes (Coulombs per second), the rate in which a battery can be recharged in Amperes, the initial charge of the first battery in Coulombs and the initial charge of the seco …
출력 요약
Output one integer with the number of seconds a phone will last given an ICPC dual battery as described in the statement. Round down your answer in case it’s nonintegral.
코드
a,b,c,d=map(int,input().split())
print((c+d)//(a-b))
설명
핵심은 구현 관점에서 “I once met an interesting guy who had a phone with two batteries.” - Dudu, 2014 …를 만족하도록 로직을 구성하는 것입니다.
코드는 입력을 파싱한 뒤 조건 분기와 계산을 순서대로 수행하고, 문제에서 요구한 형식으로 결과를 출력합니다.
경계값과 예외 케이스도 함께 고려해 오답이 나기 쉬운 상황을 방지합니다.
댓글남기기