Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- const int N = 1e6 + 3;
- const int mod = 1e9 + 7;
- int n, x;
- int dp[N], a[N];
- int main(){
- cin >> n >> x;
- for (int i = 1; i <= n; i++) {
- cin >> a[i];
- }
- dp[0] = 1;
- for (int i = 1; i <= n; i++) {
- for (int j = 1; j <= x; j++) {
- if (j - a[i] >= 0) {
- dp[j] = (dp[j] + dp[j - a[i]]) % mod;
- }
- }
- }
- cout << dp[x] << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment