## 문제
BOJ 4344 평균은 넘겠지
## solution
첫 줄에는 테스트케이스 개수가 주어지고, 둘쨰 줄부터 각 테스트케이스마다 학생 수가 첫 수로 주어지고, 이어서 그 수만큼의 점수가 주어진다.
각 케이스마다 한 줄씩 평균을 넘는 학생들의 비율을 반올림하여 소수점 셋째 자리까지 출력한다.
각 케이스에서 첫 수는 점수 개수를 알려주는 숫자이므로 그 다음 숫자부터 평균을 구하고, 평균을 넘는 학생 비율을 구해서 내보내되, 소수점 셋째 자리까지 출력한다.
소숫점 셋째 자리까지 출력하는것은 포맷팅 이용하면 될것이다.
## CODE
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case_input = int(input()) | |
case_list = [] | |
for tmp in range(case_input): | |
line_input = list(map(int,input().split())) | |
#line input에서 0번 인덱스는 제외하고, 1번부터 끝까지 평균 구해서 계산후 저장 | |
line_average = sum(line_input[1:])/(len(line_input) - 1) | |
above_average = 0 | |
for k in range(1,len(line_input)): | |
if line_input[k] > line_average: | |
above_average += 1 | |
line_rate = above_average/(len(line_input) - 1)*100 | |
case_list += [line_rate] | |
for k in case_list: | |
print('{:.3f}'.format(k),end='') | |
print('%') |
formatting 방법은 알아두기로 하자.
0 댓글