From 5dddc3a9466a93e631b81af621748a289707688c Mon Sep 17 00:00:00 2001 From: sieunnnn Date: Tue, 17 Oct 2023 19:38:09 +0900 Subject: [PATCH] =?UTF-8?q?=EB=B0=B1=EC=A4=80/=EA=B3=A8=EB=93=9C:=2011050?= =?UTF-8?q?=20=EC=9D=B4=ED=95=AD=20=EA=B3=84=EC=88=98=201=20=EB=AC=B8?= =?UTF-8?q?=EC=A0=9C=ED=92=80=EC=9D=B4=20(#23)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/baekjoon/step/combinatoric/PROB11050.java | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/baekjoon/step/combinatoric/PROB11050.java diff --git a/src/baekjoon/step/combinatoric/PROB11050.java b/src/baekjoon/step/combinatoric/PROB11050.java new file mode 100644 index 0000000..9723c58 --- /dev/null +++ b/src/baekjoon/step/combinatoric/PROB11050.java @@ -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); + } +}