■코테 중요개념/다이나믹 프로그래밍(DP)

[백준 11726] 2xn 타일링

영민 박 2020. 4. 30. 15:43

▶ 코드

 

# 1, 2, 3, 5, 8, 13, 21, 34, 55 ...

N = int(input())

memo = [0]*1001

def fib(N):
    if N == 1:
        return 1
    if N == 2:
        return 2
    if memo[N] != 0:
        return memo[N]
    else:
        memo[N] = fib(N-1) + fib(N-2)
        return memo[N]

print( fib(N) % 10007 )
저작자표시 비영리 변경금지 (새창열림)