[백준/파이썬] 15025번 풀이
업데이트:
문제 정보
- 문제 출처: 백준 온라인 저지
- 문제 링크: 15025번 문제
- 문제풀이 코드 GitHub 링크
- 제출 언어: Python 3
풀이
문제
When determining the age of a bull moose, the number of tines (sharp points), extending from the main antlers, can be used. An older bull moose tends to have more tines than a younger moose. However, just counting the number of tines can be misleading, as a moose can break off the tines, for example when fighting with other moose. …
입력 요약
The input contains a single line with two integers ℓ and r, where 0 ≤ ℓ ≤ 20 is the number of tines on the left, and 0 ≤ r ≤ 20 is the number of tines on the right.
출력 요약
Output a single line describing the moose. For even pointed moose, output “Even x” where x is the points of the moose. For odd pointed moose, output “Odd x” where x is the points of the moose. If the moose has no tines, output “Not a moose”
코드
l,r=map(int,input().split())
if l==r==0:print('Not a moose')
elif l==r:print('Even',l+r)
else:print('Odd',max(l,r)*2)
설명
핵심은 구현 관점에서 When determining the age of a bull moose, the number of tines (sharp points), extending from the main antlers, can be used. …를 만족하도록 로직을 구성하는 것입니다.
코드는 입력을 파싱한 뒤 조건 분기와 계산을 순서대로 수행하고, 문제에서 요구한 형식으로 결과를 출력합니다.
경계값과 예외 케이스도 함께 고려해 오답이 나기 쉬운 상황을 방지합니다.
댓글남기기