[알고리즘/백준] 9625번 : BABBA(python)

유현민·2022년 3월 5일
0

알고리즘

목록 보기
36/253

dp로 간단하게 구현해서 풀었다.

def solution(K):
    ba = [[] for _ in range(46)]
    ba[0] = [1, 0]
    ba[1] = [0, 1]
    for t in range(2, K + 1):
        ba[t] = [i + j for i, j in zip(ba[t - 1], ba[t - 2])]

    print(ba[K][0], ba[K][1])


if __name__ == "__main__":
    solution(int(input()))
profile
smilegate megaport infra

0개의 댓글