import sys
from collections import Counter
def input():
    return sys.stdin.readline().rstrip()

cnt = 0
total_dict = Counter()
while True:
    name = input()
    if not name:
        break
    total_dict[name] += 1
    cnt += 1

key_list = sorted(total_dict.keys())

for key in key_list:
    print(f'{key} {total_dict[key]*100/cnt:.4f}')

 

 

이 문제는 골드5라 되어있지만, 실버 수준인것 같다.

 

어려운 알고리즘도 없고, 단순히 formating을 이용한 반올림을 하면 된다.

 

 

전체 수를 딕셔너리에 저장을 하고, 정렬을 한뒤에 4자리까지만 출력되게 하면 된다.

 

'알고리즘 > 백준' 카테고리의 다른 글

[BOJ/백준] 13711 LCS 4  (0) 2021.07.12
[BOJ/백준] 13397 구간 나누기 2  (0) 2021.07.12
[BOJ/백준] 16947 서울 지하철 2호선  (0) 2021.07.12
[BOJ/백준] 16472 고냥이  (0) 2021.06.29
[BOJ/백준] 16398 행성 연결  (0) 2021.06.29

+ Recent posts