반응형

[ Contents ]
1. 문제 (링크 참조)
15025번: Judging Moose
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
www.acmicpc.net
2. 문제 풀이
양쪽의 뿔에서 뻗어 나온 가지의 개수가 주어집니다. 양쪽 뿔의 개수가 같다면 "Even 가지 갯수"를 출력하고, 같지 않다면 "Odd 더 많은 가지의 개수 * 2"를 출력합니다.
3. 코드
# 입력
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)
만약 가지의 개수가 0이면, "Not a moose"를 출력합니다.

반응형
'Algorithm' 카테고리의 다른 글
| [동적계획법/DP] 백준 1660 캡틴 이다솜 - 파이썬(Python) (0) | 2022.09.03 |
|---|---|
| [구현/수학] 백준 17874 Piece of Cake! - 파이썬(Python) (0) | 2022.09.02 |
| [DP/동적계획법] 백준 14495 피보나치 비스무리한 수열 - 파이썬(Python) (0) | 2022.08.31 |
| [DP/동적계획법] 백준 1788 피보나치 수의 확장 - 파이썬(Python) (0) | 2022.08.30 |
| [구현/수학] 백준 16017 Telemarketer or not? - 파이썬(Python) (0) | 2022.08.29 |
댓글