Skip to content

Commit bb09b76

Browse files
committed
[Combination] baekjoon-11051
1 parent 0c9cfcb commit bb09b76

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,5 @@
6969

7070
| # || Problem | Note |
7171
| :-: | :----: | :------------------------------------------------------------------------------------------------------------------ | :------------------------ |
72-
| 01 | | [Baekjoon-11050 이항 계수 1](https://github.com/Seogeurim/Algorithm-practice/blob/master/src/Combination/P11050) | |
72+
| 01 | | [Baekjoon-11050 이항 계수 1](https://github.com/Seogeurim/Algorithm-practice/blob/master/src/Combination/P11050) | |
73+
| 02 | | [Baekjoon-11051 이항 계수 2](https://github.com/Seogeurim/Algorithm-practice/blob/master/src/Combination/P11051) | DP |

src/Combination/P11051/Main.java

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

0 commit comments

Comments
 (0)