From 4d8075812b30b0c393f8e51a3da3056d88f4d84d Mon Sep 17 00:00:00 2001 From: Gyunseo Lee Date: Mon, 13 May 2024 00:38:04 +0900 Subject: [PATCH] 2024-05-13 00:38:03 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Affected files: .obsidian/workspace.json src/content/blog/boj-11507-오르막-수.md --- .obsidian/workspace.json | 29 +++++++--- ...4\353\245\264\353\247\211-\354\210\230.md" | 55 +++++++++++++++++++ 2 files changed, 76 insertions(+), 8 deletions(-) create mode 100644 "src/content/blog/boj-11507-\354\230\244\353\245\264\353\247\211-\354\210\230.md" diff --git a/.obsidian/workspace.json b/.obsidian/workspace.json index 0a335b658..ab73c461d 100644 --- a/.obsidian/workspace.json +++ b/.obsidian/workspace.json @@ -36,8 +36,21 @@ "source": false } } + }, + { + "id": "7b3dd1b0a75c5d97", + "type": "leaf", + "state": { + "type": "markdown", + "state": { + "file": "src/content/blog/boj-11507-오르막-수.md", + "mode": "source", + "source": false + } + } } - ] + ], + "currentTab": 1 } ], "direction": "vertical" @@ -103,7 +116,7 @@ "state": { "type": "backlink", "state": { - "file": "src/content/blog/boj-1912-연속합.md", + "file": "src/content/blog/boj-11507-오르막-수.md", "collapseAll": false, "extraContext": false, "sortOrder": "alphabetical", @@ -120,7 +133,7 @@ "state": { "type": "outgoing-link", "state": { - "file": "src/content/blog/boj-1912-연속합.md", + "file": "src/content/blog/boj-11507-오르막-수.md", "linksCollapsed": false, "unlinkedCollapsed": true } @@ -143,7 +156,7 @@ "state": { "type": "outline", "state": { - "file": "src/content/blog/boj-1912-연속합.md" + "file": "src/content/blog/boj-11507-오르막-수.md" } } } @@ -166,10 +179,11 @@ "table-editor-obsidian:Advanced Tables Toolbar": false } }, - "active": "fbca317c99f1a7a9", + "active": "7b3dd1b0a75c5d97", "lastOpenFiles": [ - "src/content/blog/boj-1699-제곱수의-합.md", "src/content/blog/boj-1912-연속합.md", + "src/content/blog/boj-11507-오르막-수.md", + "src/content/blog/boj-1699-제곱수의-합.md", "src/content/blog/boj-15666-N과-M-(12).md", "src/content/blog/boj-1940-주몽.md", "src/content/blog/boj-11725-트리의-부모-찾기.md", @@ -212,7 +226,6 @@ "src/content/blog/24-sw-maestro-1st-coding-test.md", "src/content/blog/programmers-인기있는-아이스크림.md", "src/content/blog/programmers-가장-비싼-상품-구하기.md", - "src/assets/template/obsidian-template.md", - "src/content/blog/ubuntu-partition.md" + "src/assets/template/obsidian-template.md" ] } \ No newline at end of file diff --git "a/src/content/blog/boj-11507-\354\230\244\353\245\264\353\247\211-\354\210\230.md" "b/src/content/blog/boj-11507-\354\230\244\353\245\264\353\247\211-\354\210\230.md" new file mode 100644 index 000000000..15f216ace --- /dev/null +++ "b/src/content/blog/boj-11507-\354\230\244\353\245\264\353\247\211-\354\210\230.md" @@ -0,0 +1,55 @@ +--- +author: Gyunseo Lee +title: "BOJ 백준 11507: 오르막 수" +pubDatetime: 2024-05-13T00:35:00+09:00 +modDatetime: 2024-05-13T00:35:00+09:00 +featured: false +draft: false +tags: + - PS + - Algorithms + - BOJ + - DP + - 실랜디 +description: "백준 11507: 오르막 수 풀이 과정" +ogImage: "" +--- + +## Table of contents + +## 들어가며 + +이 문제는 완탐으로 풀려고 하면요. +무려 $10^{1000}$ 이라는 미친 가짓수가 나와서, 완탐으로는 못 풀어서 딴 풀이를 생각해야 합니다. +그래서 저는 DP를 의심했습니다. +왜냐면, 일일히 가짓수를 세보는데 전에 세었던 가짓수가 필요하더라고요. + +## 풀이 과정 + +![](https://res.cloudinary.com/gyunseo-blog/image/upload/f_auto/v1715528268/image_rpxozq.png) + +## AC 받은 Python 코드 + +```python +import sys + +input = sys.stdin.readline +MOD = 10_007 +if __name__ == "__main__": + N = int(input().rstrip()) + dp = [[0 for _ in range(10)] for __ in range(N + 1)] + for i in range(10): + dp[1][i] = 1 + for i in range(2, N + 1): + for j in range(10): + tmp_sum = 0 + for k in range(j, 10): + tmp_sum += dp[i - 1][k] + dp[i][j] = tmp_sum % MOD + ans = 0 + for i in range(10): + # print(f"dp[{N}][{i}]: {dp[N][i]}") + ans += dp[N][i] % MOD + print(ans % MOD) + +```