-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathd.cpp
More file actions
34 lines (31 loc) · 725 Bytes
/
d.cpp
File metadata and controls
34 lines (31 loc) · 725 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
#include <bits/stdc++.h>
#define endl '\n'
#define eat cin
#define moo cout
#define int long long
using namespace std;
int MOD = 1e9+7;
int N, a[1000];
int dp[1001][20001];
int32_t main(){
eat.tie(0) -> sync_with_stdio(0);
eat >> N;
for(int i = 0; i < N; i++){
eat >> a[i];
}
dp[0][10000] = 1;
int ans = 0;
for(int i = 0; i < N; i++){
for(int j = 0; j+a[i] <= 20000; j++){
dp[i+1][j+a[i]] = (dp[i][j] + dp[i+1][j+a[i]]) % MOD;
dp[i+1][j] = (dp[i][j+a[i]] + dp[i+1][j]) % MOD;
}
ans = (ans + dp[i+1][10000]) % MOD;
/*for(int j = 0; j <= 20000; j++){
ans = (ans + dp[i+1][j] * dp[i][j] % MOD) % MOD;
dp[i+1][j] = (dp[i][j] + dp[i+1][j]) % MOD;
}*/
dp[i+1][10000]++;
}
moo << ans << endl;
}