Skip to content

Commit

Permalink
백준/골드: 11050 이항 계수 1 문제풀이 (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
sieunnnn committed Oct 17, 2023
1 parent aeffcb9 commit 5dddc3a
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/baekjoon/step/combinatoric/PROB11050.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package baekjoon.step.combinatoric;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class PROB11050 {
// nCr = r! / n!(n - r)!

static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
static StringTokenizer st;
static int a, b;

public static void main(String[] args) throws IOException {
st = new StringTokenizer(br.readLine());
a = Integer.parseInt(st.nextToken());
b = Integer.parseInt(st.nextToken());

System.out.println(fac(a) / (fac(b) * fac(a - b)));
}

public static int fac (int n) {
if (n == 0) {
return 1;
}

return n * fac(n - 1);
}
}

0 comments on commit 5dddc3a

Please sign in to comment.