-
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.
- Loading branch information
1 parent
801a1f2
commit 78e03d7
Showing
1 changed file
with
36 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package jimin.`23week` | ||
|
||
/* | ||
<문제> | ||
[합분해](https://www.acmicpc.net/problem/2225) | ||
<구현 방법> | ||
n은 n - m에 m을 더한 것이다. | ||
이 m은 0 ~ n까지 이다. | ||
DP[K][N] = DP[K-1][0] + DP[K-1][1] + ... + DP[K-1][N] | ||
<트러블 슈팅> | ||
오늘도 구글링..^^ https://hongjw1938.tistory.com/63 | ||
*/ | ||
|
||
class 합분해 { | ||
fun solve() { | ||
val (n, k) = readln().split(" ").map{ it.toInt() } | ||
val dp = MutableList(k + 1){ MutableList(n + 1) { 0 } } | ||
dp[1] = MutableList(n + 1) { 1 } | ||
|
||
for(i in 2 .. k) { | ||
for(j in 0 .. n) { | ||
for (k in 0 .. j) { | ||
dp[i][j] += dp[i - 1][k] | ||
dp[i][j] %= 1_000_000_000 | ||
} | ||
} | ||
} | ||
println(dp.last().last()) | ||
} | ||
} | ||
|
||
fun main() { | ||
합분해().solve() | ||
} |