[백준/파이썬] 15600번 풀이
업데이트:
문제 정보
- 문제 출처: 백준 온라인 저지
- 문제 링크: 15600번 문제
- 문제풀이 코드 GitHub 링크
- 제출 언어: Python 3
풀이
문제
You are stuck at a boss level of your favourite video game. The boss battle happens in a circular room with n indestructible pillars arranged evenly around the room. The boss hides behind an unknown pillar. Then the two of you proceed in turns.
-
First, in your turn, you can throw a bomb past one of the pillars. The bomb will defeat the boss if it is behind that pillar, or either of the adjacent pillars.
-
Next, if the boss was not defeated, it may either stay where it is, or use its turn to move to a pillar that is adjacent to its current position. …
입력 요약
The input consists of:
- One line with a single integer n (1 ≤ n ≤ 100), the number of pillars in the room.
출력 요약
Output the minimum number of bombs needed to defeat the boss in the worst case.
코드
print(max(int(input())-2,1))
설명
핵심은 구현 관점에서 You are stuck at a boss level of your favourite video game. The boss battle happens in a circular room with n indestructible pillars arranged evenly a …를 만족하도록 로직을 구성하는 것입니다.
코드는 입력을 파싱한 뒤 조건 분기와 계산을 순서대로 수행하고, 문제에서 요구한 형식으로 결과를 출력합니다.
경계값과 예외 케이스도 함께 고려해 오답이 나기 쉬운 상황을 방지합니다.
댓글남기기