-
Notifications
You must be signed in to change notification settings - Fork 0
/
CSES1636.cpp
58 lines (45 loc) · 859 Bytes
/
CSES1636.cpp
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include<bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define mp make_pair
#define pb push_back
ll gcd(ll a, ll b)
{
if (a == 0)
return b;
if (b == 0)
return a;
if (a == b)
return a;
if (a > b)
return gcd(a - b, b);
return gcd(a, b - a);
}
using namespace std;
const int MOD = 1e9 + 7;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n,x;
cin >> n >> x;
int dp[x + 1];
int coins[n];
for(int i = 0; i < n; i++)
cin >> coins[i];
for(int i = 1; i <= x; i++)
dp[i] = 0;
dp[0] = 1;
for(int i = 0; i < n; i++) {
for(int j = coins[i]; j <= x; j++) {
dp[j] += dp[j - coins[i]];
dp[j] %= MOD;
}
}
cout << dp[x];
}
/*
RILY <3
NEVER GIVE UP!!!
3
*/