import math
import sys
input = sys.stdin.readline
def BOJ4344() :
C = int(input())
for _ in range(C) :
inputs = list(map(int, input().split()))
total = inputs[0]
scores = inputs[1:]
standard = sum(scores) / total
over_standard_scores = list(filter(lambda x: float(x) > standard, scores))
# result = math.floor(((len(over_standard_scores) / total * 100) + 0.0005) * 1000) / 1000
result = round((len(over_standard_scores) / total) * 100, 3)
# print(f"{a}%")
print(str("%.3f" % result) + '%')
BOJ4344()
접근 방법 :
1. 문제가 간단한 편이라 따로 서술하지 않겠습니다!! 출력 형식에만 주의하시면 됩니다!
장애물 이였던 것 :
1. 출력형식에 있어 애를 먹었다. 주석처리 되어있는 부분이 그 증거다.
1-1 출력 형식에 대한 정리는 따로 포스팅 하겠습니다!
2. round 함수를 활용하지 않고 0.5를 더해준후 내림을 통해 반올림을 구현하고 있었다. round가 더 간결하고 쓰기 좋은것 같다
https://www.acmicpc.net/problem/4344
4344번: 평균은 넘겠지
대학생 새내기들의 90%는 자신이 반에서 평균은 넘는다고 생각한다. 당신은 그들에게 슬픈 진실을 알려줘야 한다.
www.acmicpc.net
'알고리즘' 카테고리의 다른 글
돌 게임 [백준 9655] - python (0) | 2022.01.28 |
---|---|
토마토 [백준 7576] - python (0) | 2022.01.27 |
1,2,3 더하기 [백준 9095] - python (0) | 2022.01.14 |
패션왕 신해빈 (0) | 2022.01.13 |
과제 [백준 - 13904] - python (0) | 2022.01.11 |