File tree Expand file tree Collapse file tree 1 file changed +53
-0
lines changed
Expand file tree Collapse file tree 1 file changed +53
-0
lines changed Original file line number Diff line number Diff line change 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+ ```
You can’t perform that action at this time.
0 commit comments