[프로그래머스]구슬을 나누는 경우의 수

박예림·2023년 6월 5일
0

코테

목록 보기
129/132

import java.math.BigInteger;
class Solution {
    public int solution(int balls, int share) {
        BigInteger bigNum = BigInteger.ONE;

        for (int i = balls; i > share ; i--) {
            bigNum = bigNum.multiply(BigInteger.valueOf(i));
        }
        for (int i = 2; i <= balls-share; i++) {
            bigNum = bigNum.divide(BigInteger.valueOf(i));
        }

        return bigNum.intValue();
    }
}
profile
응애 나 아기개발자

0개의 댓글

Powered by GraphCDN, the GraphQL CDN