코딩테스트 대비/단계별 코딩 테스트 준비(27일 과정)
[배열/Python] 4344번: 평균은 넘겠지 - 효과는 굉장했다!
bluetag_boy
2022. 2. 11. 14:09
반응형
4344번: 평균은 넘겠지
대학생 새내기들의 90%는 자신이 반에서 평균은 넘는다고 생각한다. 당신은 그들에게 슬픈 진실을 알려줘야 한다.
www.acmicpc.net
알고리즘 분류
- 수학
- 사칙연산
SOLUTION
import sys
C = int(sys.stdin.readline())
for _ in range(C):
N, *score = map(int, sys.stdin.readline().split())
average = sum(score) / N
cnt = 0
for i in score:
if i > average:
cnt += 1
# format함수를 이용해 소수점 셋째자리까지 출력
print("{:.3f}".format(cnt/N * 100)+"%")