From 942b9748f53467c583eb9ab82bfbaacef6ad6703 Mon Sep 17 00:00:00 2001 From: heerucan Date: Thu, 5 May 2022 22:39:51 +0900 Subject: [PATCH] [BOJ] 9095(#6) --- BOJ/9095.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 BOJ/9095.py diff --git a/BOJ/9095.py b/BOJ/9095.py new file mode 100644 index 0000000..a9436e0 --- /dev/null +++ b/BOJ/9095.py @@ -0,0 +1,18 @@ +# 백준 9095 실버3 +# 다이나믹 프로그래밍 : 1, 2, 3 더하기 + + +t = int(input()) +n = [int(input()) for i in range(t)] + +dp = [0]*11 + +dp[1] = 1 +dp[2] = 2 +dp[3] = 4 + +for j in range(len(n)): + for i in range(4, n[j] + 1): + dp[i] = dp[i - 1] + dp[i - 2] + dp[i - 3] + print(dp[n[j]]) +