-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcoin_combinations_1.cpp
More file actions
40 lines (38 loc) · 881 Bytes
/
Copy pathcoin_combinations_1.cpp
File metadata and controls
40 lines (38 loc) · 881 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
34
35
36
37
38
39
40
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mod (int)(1e9+7)
#define sz(s) (int)s.size()
#define all(v) v.begin(),v.end()
#define fill0(dp) memset(dp,0,sizeof(dp))
#define fill(dp) memset(dp,-1,sizeof(dp))
#define input(v) for (auto &i : v) cin >> i;
#define print(v) for (auto &j : v) cout << j << " "; cout << "\n";
vector<int>c(100),dp((int)(1e6)+1,0);
void solve()
{
int n,x;
cin>>n>>x;
for(int i=0;i<n;i++) cin>>c[i];
dp[0]=1;
for(int i=1;i<=x;i++)
{
for(int j=0;j<n;j++)
{
if(i-c[j]>=0)
{
(dp[i] += dp[i-c[j]])%=mod;
}
}
}
cout<<dp[x]<<"\n";
}
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);cout.tie(nullptr);
int testcases=1;
//cin>>testcases;
while(testcases--) solve();
return 0;
}