Skip to content

Commit ddce5bc

Browse files
authored
Merge pull request #1571 from AlgorithmWithGod/0224LJH
[20251203] BOJ / G5 / 합분해 / 이종환
2 parents c1b50be + 1e71ff8 commit ddce5bc

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

0224LJH/202512/03 BOJ 합분해.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
```java
2+
3+
import java.io.BufferedReader;
4+
import java.io.IOException;
5+
import java.io.InputStreamReader;
6+
import java.util.ArrayList;
7+
import java.util.Arrays;
8+
import java.util.HashSet;
9+
import java.util.List;
10+
import java.util.StringTokenizer;
11+
12+
public class Main {
13+
14+
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
15+
static int target, cnt;
16+
static long[][] dp;
17+
18+
public static void main(String[] args) throws IOException {
19+
init();
20+
process();
21+
print();
22+
23+
}
24+
25+
private static void init() throws IOException{
26+
StringTokenizer st = new StringTokenizer(br.readLine());
27+
target = Integer.parseInt(st.nextToken());
28+
cnt = Integer.parseInt(st.nextToken());
29+
dp = new long[target+1][cnt+1];
30+
}
31+
32+
private static void process() throws IOException {
33+
dp[0][0] = 1;
34+
for (int i = 0; i <= target; i++) {
35+
for (int j = 0; j <= target; j++) {
36+
if (i+j > target) break;
37+
for (int k = 1; k <= cnt; k++) {
38+
dp[i+j][k] += dp[i][k-1];
39+
dp[i+j][k] %= 1000_000_000;
40+
}
41+
}
42+
}
43+
44+
45+
}
46+
47+
48+
private static void print() {
49+
System.out.println(dp[target][cnt]);
50+
}
51+
52+
}
53+
```

0 commit comments

Comments
 (0)