Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.002 s | 0 KBi |
#2 |
Correcto
|
0.005 s | 0 KBi |
#3 |
Correcto
|
0.007 s | 18 KBi |
#4 |
Correcto
|
0.005 s | 0 KBi |
#5 |
Correcto
|
0.008 s | 0 KBi |
#6 |
Correcto
|
0.007 s | 0 KBi |
#7 |
Correcto
|
0.002 s | 0 KBi |
#8 |
Correcto
|
0.002 s | 0 KBi |
#9 |
Correcto
|
0.032 s | 0 KBi |
#10 |
Correcto
|
0.034 s | 0 KBi |
#11 |
Correcto
|
0.039 s | 6 KBi |
#12 |
Correcto
|
0.022 s | 66 KBi |
#13 |
Correcto
|
0.014 s | 0 KBi |
#14 |
Correcto
|
0.03 s | 25 KBi |
#15 |
Correcto
|
0.01 s | 47 KBi |
#include <bits/stdc++.h> using namespace std; void _print() { cerr << "]" << endl; } template<typename T, typename... V> void _print(T t, V... v) { cerr << t; if (sizeof...(v)) cerr << ", "; _print(v...); } #ifdef LOCAL #define dbg(x...) cerr << "[" << #x << "]: ["; _print(x) #else #define dbg(x...) #define endl '\n' #endif #define ll long long #define sz(x) int(x.size()) int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n; cin >> n; int den[n]; for (int &i : den) cin >> i; const int MOD = 1e9 + 7; const int MAX = 1e4 + 5; int dp[MAX] = {}; dp[0] = 1; for (int i = 0; i < n; ++i) { if (den[i] >= MAX) continue; for (int j = 1; j < MAX; ++j) { if (j - den[i] >= 0) { dp[j] += dp[j - den[i]]; dp[j] %= MOD; } } } int m; cin >> m; while (m--) { int s; cin >> s; cout << dp[s] << endl; } return 0; }