본문 바로가기

Programming [Python]/백준 알고리즘 솔루션

#73 백준 파이썬 [9095] 1, 2, 3 더하기

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

 

#Solution

def plus_123(n):
    if n == 1:
        return 1
    if n == 2:
        return 2
    if n == 3:
        return 4
    else:
        return plus_123(n-1) + plus_123(n-2) + plus_123(n-3)
    
test = int(input())

for num in range(test):
    answer = plus_123(int(input()))
    print(answer)