Written by
java-style
on
on
Baekjoon11050: 이항계수
Baekjoon11050: 이항계수
이항 계수 1
1 초 256 MB 26624 17107 14770 64.442%
풀이
입력값 N, K에 대하여 이항 계수 (N K)의 값은 N!/K!(N-K)! 이다.
팩토리얼 메소드를 활용한다.
import java.util.*; public class Main { static int Fac(int N) { if(N<=1)return 1; return Fac(N-1)*N; } public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int K = sc.nextInt(); System.out.print(Fac(N)/Fac(K)/Fac(N-K)); }}
from http://devyoseph.tistory.com/177 by ccl(A) rewrite - 2021-12-05 01:01:53