티스토리 뷰

728x90

https://www.acmicpc.net/problem/9733

 

9733번: 꿀벌

각각의 일을 한 횟수와 비율을 공백으로 구분하여 출력한다. 출력은 {Re,Pt,Cc,Ea,Tb,Cm,Ex} 순서대로 하며, 비율은 소수점 둘째 자리까지 출력한다. 주어진 목록에 없는 일은 출력하지 않는다. 입력의

www.acmicpc.net

 

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import sys
lst = ['Re', 'Pt', 'Cc', 'Ea', 'Tb', 'Cm', 'Ex']
bee = dict()
for i in lst:
    bee[i] = 0
 
cnt = 0
lines = sys.stdin.readlines()
for line in lines:
    txt = list(line.split())
    for i in txt:
        if i in lst:
            bee[i] = bee.get(i, 0) + 1
        cnt += 1
 
for i in bee:
    print(i, bee.get(i), '{:.2f}'.format(bee.get(i)/cnt))
 
print('Total', cnt, '1.00')
 
cs

 

'코딩 > 파이썬 백준' 카테고리의 다른 글

백준 2993 세 부분(파이썬)  (0) 2021.11.22
백준 4796 캠핑  (0) 2021.10.11
프로그래머스 프린터(level : 2)  (0) 2021.10.11
프로그래머스 기능개발(level : 2)  (0) 2021.10.11
파이썬 읽기, 쓰기  (0) 2021.08.18
댓글