Skip to content

Commit 0c9cfcb

Browse files
committed
[Combination] baekjoon-11050
1 parent ed693d3 commit 0c9cfcb

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

โ€ŽREADME.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,12 @@
6161
| # | โ˜† | Problem | Note |
6262
| :-: | :----: | :------------------------------------------------------------------------------------------------------------------ | :------------------------ |
6363
| 01 | | [GCD Example](https://github.com/Seogeurim/Algorithm-practice/blob/master/src/GCD/GCDTest.java) | |
64-
| 02 | | [Baekjoon-14476 ์ตœ๋Œ€๊ณต์•ฝ์ˆ˜ ํ•˜๋‚˜ ๋นผ๊ธฐ](https://github.com/Seogeurim/Algorithm-practice/tree/master/src/GCD/P14476) | ๋ˆ„์ ํ•ฉ |
64+
| 02 | | [Baekjoon-14476 ์ตœ๋Œ€๊ณต์•ฝ์ˆ˜ ํ•˜๋‚˜ ๋นผ๊ธฐ](https://github.com/Seogeurim/Algorithm-practice/tree/master/src/GCD/P14476) | ๋ˆ„์ ํ•ฉ |
65+
66+
## Combinatorics
67+
68+
### Combination
69+
70+
| # | โ˜† | Problem | Note |
71+
| :-: | :----: | :------------------------------------------------------------------------------------------------------------------ | :------------------------ |
72+
| 01 | | [Baekjoon-11050 ์ดํ•ญ ๊ณ„์ˆ˜ 1](https://github.com/Seogeurim/Algorithm-practice/blob/master/src/Combination/P11050) | |

โ€Žsrc/Combination/P11050/Main.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package Combination.P11050;
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+
11+
public static void main(String[] args) throws Exception {
12+
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
13+
StringTokenizer st = new StringTokenizer(br.readLine());
14+
15+
N = Integer.parseInt(st.nextToken());
16+
K = Integer.parseInt(st.nextToken());
17+
18+
System.out.println(combination(N, K));
19+
}
20+
21+
static int combination(int n, int k) {
22+
if (k == 0 || n == k)
23+
return 1;
24+
return combination(n-1, k-1) + combination(n-1, k);
25+
}
26+
}

0 commit comments

Comments
ย (0)