Solution
1636-Coin_Combinations_II.cpp
1#include<bits/stdc++.h>
2using namespace std;
3#define int long long
4constexpr int M=1e9+7;
5signed main(){
6 ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
7 int n,x; cin>>n>>x;
8 int a[n]; for(int i=0;i<n;++i) cin>>a[i];
9 int dp[x+1]{}; dp[0]=1;
10 for(int j=0;j<n;++j){
11 for(int i=1;i<=x;++i){
12 if(a[j]<=i){
13 dp[i]+=dp[i-a[j]],
14 dp[i]%=M;
15 }
16 }
17 }
18 cout<<dp[x]%M<<'\n';
19 return 0;
20}Editorial not yet generated for this problem. Run the editorial generation script to add hints and detailed explanations.