int getWays(int n, vector c) {
vector dp(n+1, 0);
dp[0] = 1;
for (int coin : c) {
for (int i = coin; i > n;
int m;
cin >> m;
vector c(m);
for (int i = 0; i > c[i];
cout <<getWays(n, c)<< endl;
return 0;
}
n, m = map(int,input().split())
coins = list(map(int,input().split()))
dp = [1]+[0]*n
for i in range(m):
for j in range(coins[i], n+1): dp[j]+=dp[j-coins[i]]
print(dp[-1])
In cpp
#include
using namespace std;
int getWays(int n, vector c) {
vector dp(n+1, 0);
dp[0] = 1;
for (int coin : c) {
for (int i = coin; i > n;
int m;
cin >> m;
vector c(m);
for (int i = 0; i > c[i];
cout <<getWays(n, c)<< endl;
return 0;
}
n, m = map(int,input().split())
coins = list(map(int,input().split()))
dp = [1]+[0]*n
for i in range(m):
for j in range(coins[i], n+1): dp[j]+=dp[j-coins[i]]
print(dp[-1])
def ways(n,c):
arr = [1]+[0]*n
for coin in c:
for i in range(coin, n+1):
arr[i] += arr[i-coin]
#out of for loops in new line
if n ==0:
return 0
else:
return arr[n]
def ways(n, c):
dArray = [1]+[0]*n
for coin in c:
for i in range(coin, n+1)
arr[i] += arr[i-coin]
#out of for loops on new line
if n == 0:
return 0
else:
return arr[n]