-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path11051.java
More file actions
23 lines (19 loc) · 781 Bytes
/
11051.java
File metadata and controls
23 lines (19 loc) · 781 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String[] input = br.readLine().split(" ");
br.close();
int N = Integer.parseInt(input[0]);
int K = Integer.parseInt(input[1]);
int[][] dp = new int[N + 1][K + 1];
System.out.println(combination(dp, N, K));
}
public static int combination(int[][] dp, int n, int k) {
if(dp[n][k] != 0) return dp[n][k];
if(n == k || k == 0) return dp[n][k] = 1;
return dp[n][k] = (combination(dp, n - 1, k) + combination(dp, n - 1, k - 1)) % 10007;
}
}