Case = int(input())
num_list = list(map(int, input().split(' ')))

res_counting = 0

for i in num_list:
    cnt = 0
    if(i == 1):
        continue
    for j in range(2, i + 1):
        if(i % j == 0):
            cnt += 1
    if(cnt == 1):
        res_counting += 1
print(res_counting)

'# 코딩 문제 관련 > 파이썬' 카테고리의 다른 글

백준 2581번(python)  (0) 2019.05.31
백준 1929번(python)  (0) 2019.05.31
백준 1181번(python)  (0) 2019.05.30
백준 2108번(python)  (0) 2019.05.30
백준 1427번(python)  (0) 2019.05.29


num = int(input())
word_list = []
for word in range(num):
    word_list.append(input())
word_list = set(word_list)
word_dict = dict()
for word in word_list:
    word_dict[word] = len(word)
word_dict = sorted(word_dict, key = lambda x :  [len(x), x.lower()])
for word in word_dict:
    print(word)

'# 코딩 문제 관련 > 파이썬' 카테고리의 다른 글

백준 1929번(python)  (0) 2019.05.31
백준 1978번(python)  (0) 2019.05.31
백준 2108번(python)  (0) 2019.05.30
백준 1427번(python)  (0) 2019.05.29
백준 2751번(python)  (0) 2019.05.29


import sys
from collections import Counter
  
t = int(sys.stdin.readline())
num_list = []
for _ in range(t):
    num_list.append(int(sys.stdin.readline())) 

def mode(x):
    mode_dict = Counter(x)
    modes = mode_dict.most_common()
    if len(x) > 1 : 
        if modes[0][1] == modes[1][1]:
            mod = modes[1][0]
        else : 
            mod = modes[0][0]
    else : 
        mod = modes[0][0]
    
    return mod

print(round(sum(num_list) / len(num_list)))
num_list.sort()
print(num_list[len(num_list) // 2])
print(mode(num_list))
print(num_list[-1] - num_list[0])

- Counter()는 각 num에 대해 빈도수를 dict로 만들어줌

- most_common()은 배열안에 튜플 형식으로 최빈값부터 2번째로 자주 나오는 수.... 를 반환함

- 최빈값이 여러 개인 경우, key값이 작은 것부터 정렬해서 나타내줌.

- 따라서 문제에서는 두번째로 작은 값이므로 1번째 것을 가져오면 됨

'# 코딩 문제 관련 > 파이썬' 카테고리의 다른 글

백준 1978번(python)  (0) 2019.05.31
백준 1181번(python)  (0) 2019.05.30
백준 1427번(python)  (0) 2019.05.29
백준 2751번(python)  (0) 2019.05.29
백준 2750번(python)  (0) 2019.05.29


str_list = input()
num_list = list()
for i in str_list:
    num_list.append(int(i))
num_list = reversed(sorted(num_list))
res = ''
for i in num_list:
    res += str(i)
print(res)

'# 코딩 문제 관련 > 파이썬' 카테고리의 다른 글

백준 1181번(python)  (0) 2019.05.30
백준 2108번(python)  (0) 2019.05.30
백준 2751번(python)  (0) 2019.05.29
백준 2750번(python)  (0) 2019.05.29
백준 6064번(python)  (0) 2019.05.28


--시간초과,

import sys
test = [int(sys.stdin.readline()) for _ in range(int(sys.stdin.readline()))]

def make_heap(x):
    for k in reversed(range(len(x) // 2)):
        heapify(x, len(x), k)
        
def heapify(x, n, k):
    left = 2*k + 1
    right = 2 * k + 2

    # 부모와 자식간의 크기 비교
    if(x[k] > x[left] and left < n):
        m = k
    else:
        m = left

    if(right < n and x[m] < x[right]):
        m = right

    # 부모가 바뀐 경우.
    if k != m:
        x[k], x[m] = x[m], x[k]
        k = m
        heapify(x, n, k)
        
def heap_sort(x):
    make_heap(x)
    n = len(x)
    for k in range(len(x) - 1):
        x[0], x[n-1] = x[n-1], x[0]
        n = n - 1
        heapify(x, n, 0)
heap_sort(test)
for i in test:
    print(i)

'# 코딩 문제 관련 > 파이썬' 카테고리의 다른 글

백준 2108번(python)  (0) 2019.05.30
백준 1427번(python)  (0) 2019.05.29
백준 2750번(python)  (0) 2019.05.29
백준 6064번(python)  (0) 2019.05.28
백준 1475번(python)  (0) 2019.05.28