Coin Combinations I CSES dynamic programming problem set solution -
Problem statement-
Consider a money system consisting of coins. Each coin has a positive integer value. Your task is to calculate the number of distinct ways you can produce a money sum using the available coins.
For example, if the coins are and the desired sum is , there are ways:
The first input line has two integers and : the number of coins and the desired sum of money.
The second line has distinct integers : the value of each coin.
Output
Print one integer: the number of ways modulo .
Constraints
Input:
Output:
For example, if the coins are and the desired sum is , there are ways:
The first input line has two integers and : the number of coins and the desired sum of money.
The second line has distinct integers : the value of each coin.
Output
Print one integer: the number of ways modulo .
Constraints
Input:
3 9
2 3 5
Output:
8
Code Solution -
Comments
Post a Comment