[백준/파이썬] 17588번 풀이
업데이트:
문제 정보
- 문제 출처: 백준 온라인 저지
- 문제 링크: 17588번 문제
- 문제풀이 코드 GitHub 링크
- 제출 언어: Python 3
풀이
문제
You enjoy your new job as a teacher of young children. It’s fun to see them learning to count, recognize letters, draw, and interact with the world.
One common problem you’ve noticed is that children often forget numbers when counting. For example, early on they might count “one, two, three, five, six.” You have to remind them about that “four” that they didn’t say. …
입력 요약
The first line of input contains a single integer n, where 1 ≤ n ≤ 100. Each of the next n lines contains one number that the child recited. Each recited number is an integer between 1 and 200 (inclusive). They are listed in increasing order, and there are no duplicates.
출력 요약
If the child recited all the numbers between 1 and the last number they recited, then print good job.
If the child missed any numbers between 1 and the last number they recited, then print those missing numbers in increasing numeric order, one per line.
코드
l=[int(input())for _ in range(int(input()))]
s=set([i+1 for i in range(max(l))])
s=sorted(s-set(l))
print('\n'.join(map(str,s))if s else'good job')
설명
핵심은 구현 관점에서 You enjoy your new job as a teacher of young children. It’s fun to see them learning to count, recognize letters, draw, and interact with the world. …를 만족하도록 로직을 구성하는 것입니다.
코드는 입력을 파싱한 뒤 조건 분기와 계산을 순서대로 수행하고, 문제에서 요구한 형식으로 결과를 출력합니다.
경계값과 예외 케이스도 함께 고려해 오답이 나기 쉬운 상황을 방지합니다.
댓글남기기