-
Notifications
You must be signed in to change notification settings - Fork 2
/
Main.java
30 lines (23 loc) Β· 852 Bytes
/
Main.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package Combination.P11051;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main {
static int N,K;
static int combis[][];
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer(br.readLine());
N = Integer.parseInt(st.nextToken());
K = Integer.parseInt(st.nextToken());
combis = new int[N+1][K+1];
for (int i = 1; i <= N; i++) {
for (int j = 0; j <= K; j++) {
if (j == 0 || i == j)
combis[i][j] = 1;
else combis[i][j] = (combis[i-1][j-1] + combis[i-1][j]) % 10007;
}
}
System.out.println(combis[N][K]);
}
}