문제 설명
해결과정
Solution.java
import java.math.BigInteger;
class Solution {
public BigInteger solution(int balls, int share) {
BigInteger a = factorial(balls);
BigInteger b = factorial(balls-share);
BigInteger c = factorial(share);
BigInteger d = b.multiply(c);
BigInteger answer = a.divide(d);
return answer;
}
public BigInteger factorial(int num) {
BigInteger result = BigInteger.ONE;
for (int i = 2; i <= num; i++) {
result = result.multiply(BigInteger.valueOf(i));
}
return result;
}
}
Java
복사