From 3a802d35c3beebf2b7de1fa9f41a7557edbcd452 Mon Sep 17 00:00:00 2001 From: sm4640 Date: Fri, 27 Mar 2026 15:43:53 +0900 Subject: [PATCH] =?UTF-8?q?11726-s3=20=EC=84=B1=EA=B3=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- workbook_7319/silver/11726-s3.py | 33 ++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 workbook_7319/silver/11726-s3.py diff --git a/workbook_7319/silver/11726-s3.py b/workbook_7319/silver/11726-s3.py new file mode 100644 index 0000000..e5f2ed3 --- /dev/null +++ b/workbook_7319/silver/11726-s3.py @@ -0,0 +1,33 @@ +# 2xn 타일링 + +import sys + +input = sys.stdin.readline + +def solution(): + n = int(input().rstrip()) + + MOD = 10007 + + dp = [0] * (n+1) + dp[0] = 1 + dp[1] = 1 + + for i in range(2, n+1): + dp[i] = (dp[i-1] + dp[i-2])%MOD + + print(dp[n]) + + return + + +solution() + +""" +걸린 시간: 6분 + +시간 복잡도: dp 테이블 n개 채우면 O(n)이다. + +해설: 현재 보는 칸이 생겼을 때 1x2를 넣으려면 i-1칸까지 차있는 상태에서 넣으면 되고, 2x1을 넣으려면 i-2칸까지 차있는 상태에서 넣어야 한다. +따라서 dp[i-1] + dp[i-2]이다. +""" \ No newline at end of file