#include <bits/stdc++.h> #define gc getchar #define gcu getchar_unlocked #define fi first #define se second #define pb push_back #define mod ((ll)1e9 + 7) typedef long long ll; using namespace std; //=============================================================================================== int n, base = 1; ll ans; int a[10009]; ll d[100009]; //=============================================================================================== int main() { scanf("%d", &n); while (base < 5000) base <<= 1; for (int i = 0; i < n; i++) scanf("%d", &a[i]); sort(a, a + n); d[0] = 1; for (int i = 0; i < n; i++) { d[5001] <<= 1; d[5001] %= mod; for (int j = 5000; j >= a[i] - 1; j--) { d[min(j + a[i], 5001)] += d[j]; d[min(j + a[i], 5001)] %= mod; } } for (int i = 1; i <= 5001; i++) { ans += d[i]; ans %= mod; } printf("%lld\n", ans); } //=============================================================================================== // 5 // 2 7 4 4 1
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 | #include <bits/stdc++.h> #define gc getchar #define gcu getchar_unlocked #define fi first #define se second #define pb push_back #define mod ((ll)1e9 + 7) typedef long long ll; using namespace std; //=============================================================================================== int n, base = 1; ll ans; int a[10009]; ll d[100009]; //=============================================================================================== int main() { scanf("%d", &n); while (base < 5000) base <<= 1; for (int i = 0; i < n; i++) scanf("%d", &a[i]); sort(a, a + n); d[0] = 1; for (int i = 0; i < n; i++) { d[5001] <<= 1; d[5001] %= mod; for (int j = 5000; j >= a[i] - 1; j--) { d[min(j + a[i], 5001)] += d[j]; d[min(j + a[i], 5001)] %= mod; } } for (int i = 1; i <= 5001; i++) { ans += d[i]; ans %= mod; } printf("%lld\n", ans); } //=============================================================================================== // 5 // 2 7 4 4 1 |