File tree Expand file tree Collapse file tree 1 file changed +44
-0
lines changed
Expand file tree Collapse file tree 1 file changed +44
-0
lines changed Original file line number Diff line number Diff line change 1+ ```
2+ import java.io.*;
3+ import java.util.*;
4+
5+ public class Main {
6+ private static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
7+ private static final BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
8+ private static final int INF = (int)1e9+3;
9+ private static int[][] dp;
10+ private static int N, K;
11+
12+ public static void main(String[] args) throws IOException {
13+ init();
14+ DP();
15+
16+ int answer = (dp[N-3][K-1] + dp[N-1][K]) % INF;
17+ bw.write(answer + "\n");
18+ bw.flush();
19+ bw.close();
20+ br.close();
21+ }
22+
23+ private static void init() throws IOException {
24+ N = Integer.parseInt(br.readLine());
25+ K = Integer.parseInt(br.readLine());
26+
27+ dp = new int[N][K+1];
28+
29+ for (int i = 0; i < N; i++) {
30+ dp[i][0] = 1;
31+ }
32+
33+ dp[1][1] = 1;
34+ }
35+
36+ private static void DP() {
37+ for (int i = 2; i < N; i++) {
38+ for (int j = 1; j <= K; j++) {
39+ dp[i][j] = (dp[i-1][j] + dp[i-2][j-1]) % INF;
40+ }
41+ }
42+ }
43+ }
44+ ```
You can’t perform that action at this time.
0 commit comments