본문 바로가기

코딩테스트 준비

백준 9095번 1, 2, 3 더하기

import sys
n = int(sys.stdin.readline().rstrip())
count = 0
def counting(k):
global count
if k == 0:
count += 1
return
if k >= 1:
counting(k-1)
if k >= 2:
counting(k-2)
if k >= 3:
counting(k-3)
for i in range(n):
v = int(sys.stdin.readline().rstrip())
count = 0
counting(v)
print(count)

 

'코딩테스트 준비' 카테고리의 다른 글

이진 탐색, 이진 탐색 트리.  (0) 2021.02.14
정렬 알고리즘  (0) 2021.02.10
백준 10828 스택  (0) 2021.02.07
백준 1924번 2007년  (0) 2021.02.06
백준 4673번 셀프넘버  (0) 2021.02.06