[백준/파이썬] 17783번 풀이
업데이트:
문제 정보
- 문제 출처: 백준 온라인 저지
- 문제 링크: 17783번 문제
- 문제풀이 코드 GitHub 링크
- 제출 언어: Python 3
풀이
문제
Your parents decided that it would be “fun” to spend the entire Sunday walking near the Mookerheide close to Nijmegen.
Although you can pass the time by solving programming problems in your head, your siblings do not have the same luxury. After a short while, your younger sister Alice and your big brother Bob find themselves hopelessly bored. Together, they try to figure out if they can pass the time with a game (a problem that would later be referred to as the Bob and Alice Pastime Conundrum). …
입력 요약
- A line containing a single integer 2 ≤ n ≤ 109, the length of the branch.
출력 요약
-
On the first line print the name of the person who wins, Alice or Bob.
-
If Alice can win, print the length of a piece of branch Alice can break off as a winning move. …
코드
import sys;read=sys.stdin.readline
n=int(input())
print('Alice\n1'if n%2==0 else'Bob')
설명
핵심은 구현 관점에서 Your parents decided that it would be “fun” to spend the entire Sunday walking near the Mookerheide close to Nijmegen. …를 만족하도록 로직을 구성하는 것입니다.
코드는 입력을 파싱한 뒤 조건 분기와 계산을 순서대로 수행하고, 문제에서 요구한 형식으로 결과를 출력합니다.
경계값과 예외 케이스도 함께 고려해 오답이 나기 쉬운 상황을 방지합니다.
댓글남기기