forked from satnaing/astro-paper
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Affected files: .obsidian/workspace.json src/content/blog/boj-11507-오르막-수.md
- Loading branch information
Showing
2 changed files
with
76 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
|
||
``` |