[백준/파이썬] 9286번 Gradabase 풀이
업데이트:
문제 정보
- 문제 출처: 백준 온라인 저지
- 원문 출처: High School > University of Virginia High School Programming Contest > UVa HSPC 2013 A번
- 문제 링크: 9286번 Gradabase
- 문제풀이 코드 GitHub 링크
- 제출 언어: Python 3
풀이
문제
원문
It’s the end of the year for Hunt Valley Elementary. Everyone passed their classes and is moving forward a grade; update everyone’s grade level in the database. Kindergarden is represented by a 0, First grade by a 1, and so on. The Hunt Valley Elementary is a K-6 school. Only print out student’s grade levels who are still at Hunt Valley Elementary.
입력
The first line of input is a number, n, representing the number of test cases. Each case will start with a number, m, representing the number of entries in that test case followed by a list of m integers between 0 and 6, with each number on its own line. There will be anywhere from 1 to 500 test cases with anywhere from 1 to 500 students per case
출력
For each case, output the line “Case x:” where x is the case number, on a single line, followed by a list of integers, each on a new line, between 1 and 6. If the student has graduated from the school, do not print them.
번역
각 테스트 케이스 마다 학생(?) 수와 헌트 밸리 초등학교의 학생(?) 들의 학년 정보가 주어집니다.
해당 학생들이 다음 해에 헌트 밸리 초등학교에서 몇 학년이 될 지 구하면 됩니다.
코드
import sys;read=sys.stdin.readline
r=''
for T in range(int(read())):
r+=f'Case {T+1}:\n'
for i in range(int(read())):
n=int(read())
if n<6:r+=f'{n+1}\n'
print(r)
설명
초등학교는 6학년까지이므로 6미만인 경우에만 +1하여 출력해줍니다.
댓글남기기