본문 바로가기
python-algorithm

백준 2108 통계학

by 무적김두칠 2021. 8. 24.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import sys
from collections import Counter
tmp=[]
n=int(sys.stdin.readline())
for  i in range(n):
    tmp.append(int(sys.stdin.readline()))
tmp.sort()
print(  int (round (sum(tmp)/n,0)))
print(tmp[n//2])
= Counter(tmp)
 
= f.most_common()
 
if len(tmp) > 1:
    if b[0][1== b[1][1]:
        print(b[1][0])
    else:
        print(b[0][0])
else:
    print(tmp[0])
 
print(tmp[-1]-tmp[0])
cs

학부에서 통계도 공부했었는데 .. 사실 여기 나오는 값들은 다른 라이브러리를 통해 구하지
직접 구현하진 않죠

딱히 어렵다고 할만한게 최빈값이 있는데
LIne10 ~20 까지 보시면 될것같아요

반응형

'python-algorithm' 카테고리의 다른 글

Leetcode 561. Array Partition I  (0) 2021.08.26
백준 2828 사과 담기 게임  (0) 2021.08.25
백준 10773 제로  (0) 2021.08.24
백준 11651 좌표 정렬하기 2  (0) 2021.08.24
백준 10866 덱  (0) 2021.08.24

댓글