Skip to content

Commit

Permalink
Merge pull request #64 from AlgoLeadMe/16-LJEDD2
Browse files Browse the repository at this point in the history
16-LJEDD2
  • Loading branch information
LJEDD2 authored Feb 20, 2024
2 parents 6f4b8a4 + 9b84223 commit 571265b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion LJEDD2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
| 13차시 | 2024.02.06 | 백트래킹 | <a href="https://www.acmicpc.net/problem/26169">세 번 이내에 사과를 먹자</a> | [#54](https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/54) |
| 14차시 | 2024.02.09 | 다익스트라 | <a href="https://www.acmicpc.net/problem/13549">숨바꼭질 3</a> | [#59](https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/59) |
| 15차시 | 2024.02.12 | 다이나믹 프로그래밍 | <a href="https://www.acmicpc.net/problem/1793">타일링</a><br/><a href="https://www.acmicpc.net/problem/11727">2×n 타일링 2</a> | [#62](https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/62) |

| 16차시 | 2024.02.15 | 다이나믹 프로그래밍 | <a href="https://www.acmicpc.net/problem/2133">타일 채우기</a> | [#64](https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/64) |

---
26 changes: 26 additions & 0 deletions LJEDD2/다이나믹프로그래밍/타일 채우기.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# 소요시간 2시간 (규칙찾기 20분 + 식 세우기 30분 + 문제풀기 50분 + 해결x 답보고 이해 10분)
n = int(input())
dp = [0]*10001
dp[2] = 3

for i in range(4,31,2):
dp[i] = (dp[i-2] * 3)
# 4일때는 3x2 0개 / 6일때는 3x2가 3가지 경우 * 2개 ...
for j in range(i-4,0,-2):
dp[i] += dp[j] * 2
dp[i] += 2
print(dp[n])


# 잘못 접근
# n = int(input())
# dp = [0]*10001
# dp[2] = 3
#
# for i in range(4,31,2):
# dp[i] = (dp[i-2] * 3)
# 단순히 양쪽에 2개씩인 줄 알았으나 왼쪽에 3x2 타일을 두게 되면 중복처리가 되어버림
# for j in range(i-2,0,-2):
# dp[i] += dp[j] * 2
# dp[i] += 2
# print(dp[n])

0 comments on commit 571265b

Please sign in to comment.