Skip to content

Commit

Permalink
feat : 합분해 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
jeeminimini committed Feb 19, 2023
1 parent 801a1f2 commit 78e03d7
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/main/kotlin/jimin/23week/합분해.kt
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()
}

0 comments on commit 78e03d7

Please sign in to comment.