조합론

    [알고리즘] 조합론 - 이항 계수 (자바/Java)

    목차 조합론 이항계수 https://shoark7.github.io/programming/algorithm/3-ways-to-get-binomial-coefficients 정의 이항 계수는 집합에서 원하는 개수만큼 순서없이 뽑는 조합의 가짓수를 의미한다. 즉 nCr을 구하는 알고리즘이다. 구현 1: 팩토리얼 이용 $$ nCk = \frac{n!}{{n-k}!*k!} $$ 첫 번째 정의는 팩토리얼 재귀함수를 이용하여 알고리즘으로 구현할 수 있다. public class MyBinoCo { public static void main(String[] args) { int N = 10; int K = 3; // 팩토리얼 System.out.println(fact(N) / fact(N - K) / fact(K))..

출처: https://gmnam.tistory.com/157 [Voyager:티스토리]