मध्यम 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 के लिए अनुकूलित की गई है। ऊपर दिए गए स्टेटमेंट और सीमाओं का पालन करें।

दूसरों से सीखें

समुदाय समाधान

अभी तक कोई प्रकाशित समाधान नहीं। पहला साझा करने के लिए इस चुनौती को हल करें।