모든 챌린지
보통 0명 해결 정답률 0%

Count Coin Combinations

Count ways to make an amount with unlimited coins of specified denominations.

Use any number of each supplied denomination to make amount exactly. Count combinations, not orderings: two arrangements using the same counts of each coin are the same way. Denominations are distinct and positive.

Implement coin_sums(amount, coins).

Input

amount: The total amount to make.

coins: The available distinct denominations.

Output

Return the number of unordered combinations.

제약 조건

0 ≤ amount ≤ 200. There are 0 through 10 distinct denominations, each from 1 through 200. All counts fit signed 64-bit. Amount 0 has one way: choose no coins.

예시

예시 1
입력:
coins = [1, 2]
amount = 4

예상 출력:
expected = 3
입력:
std::vector<long long> coins = {1, 2};
long long amount = 4;

예상 출력:
long long expected = 3;
입력:
long[] coins = new long[] {1, 2};
long amount = 4;

예상 출력:
long expected = 3;

설명

The combinations are four 1s, two 1s with one 2, and two 2s.

예시 2
입력:
coins = [2]
amount = 3

예상 출력:
expected = 0
입력:
std::vector<long long> coins = {2};
long long amount = 3;

예상 출력:
long long expected = 0;
입력:
long[] coins = new long[] {2};
long amount = 3;

예상 출력:
long expected = 0;

설명

Any sum of 2-valued coins is even, so 3 is impossible.

참고 자료

이 문제는 CodeUtility에 맞게 수정되었습니다. 위의 설명과 제한 조건을 따르세요.

다른 사람의 풀이 보기

커뮤니티 솔루션

아직 공개된 풀이가 없습니다. 문제를 풀고 첫 풀이를 공유하세요.