- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCoin_Combinations_II.cpp
More file actions
Latest commit
33 lines (31 loc) · 529 Bytes
/
Copy pathCoin_Combinations_II.cpp
File metadata and controls
33 lines (31 loc) · 529 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#defineendl"\n"
#definelllonglong
#definevi vector<int>
#definevll vector<longlong>
usingnamespacestd;
ll dp[1000001];
constint mod=(int)1e9+7;
intmain(){
ios::sync_with_stdio(false);
cin.tie(NULL);
int n, x;
cin>>n>>x;
vector<int> coins(n);
for(int &x : coins){
cin>>x;
}
dp[0]=1;
for(int coin : coins){
for(int i=0;i<=x;i++){
if(i-coin>=0){
dp[i]+=dp[i-coin];
dp[i]%=mod;
}
}
}
cout<<dp[x]<<endl;
}