This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 33, M = 15000, mod = 1e9+7;
int n, a[N], f[N], dp[N][M];
signed main() {
ios::sync_with_stdio(false); cin.tie(nullptr);
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a[i];
}
f[1] = 1;
f[2] = 2;
for (int i = 3; i < N; i++) {
f[i] = f[i-1] + f[i-2];
}
for (int i = 0; i < N; i++) {
for (int j = 0; j < M; j++) {
dp[i][j] = 0;
}
}
dp[0][0] = 1;
for (int i = 0; i+1 < N; i++) {
for (int j = 0; j < M; j++) {
dp[i+1][j] += dp[i][j];
dp[i+1][j] %= mod;
if (j + f[i+1] < M) {
dp[i+1][j + f[i+1]] += dp[i][j];
dp[i+1][j + f[i+1]] %= mod;
}
}
}
int x = 0;
for (int i = 0; i < n; i++) {
x += f[a[i]];
cout << dp[N-1][x] << "\n";
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |