Submission #942722

# Submission time Handle Problem Language Result Execution time Memory
942722 2024-03-11T03:32:08 Z vjudge1 Fibonacci representations (CEOI18_fib) C++17
0 / 100
1 ms 640 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) x.begin(), x.end()
#define size(x) (int)x.size()

template<class S, class T>
bool chmin(S &a, const T &b) {
  return a > b ? (a = b) == b : false;
}
template<class S, class T>
bool chmax(S &a, const T &b) {
  return a < b ? (a = b) == b : false;
}
const int mod = 1e9 + 7;

signed main() {
  cin.tie(nullptr)->sync_with_stdio(false);
  int n; cin >> n;
  int a[n];
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  int f[68];
  f[0] = 1, f[1] = 2;
  for (int i = 2; i < 68; ++i) {
    f[i] = f[i - 1] + f[i - 2];
  }
  int dp[10000];
  memset(dp, 0, sizeof(dp));
  dp[0] = 1;
  for (int i = 0; i < 68; ++i) {
    for (int j = 9999; j - f[i] >= 0; --j) {
      dp[j] += dp[j - f[i]];
      dp[j] %= mod;
    }
  }
  int pref = 0;
  for (int i = 0; i < n; ++i) {
    pref += f[a[i] - 1];
    cout << dp[pref] << '\n';
  }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 504 KB Output is correct
2 Correct 1 ms 352 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 532 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Runtime error 1 ms 604 KB Execution killed with signal 11
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 504 KB Output is correct
2 Correct 1 ms 352 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 532 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Runtime error 1 ms 604 KB Execution killed with signal 11
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 640 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 504 KB Output is correct
2 Correct 1 ms 352 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 532 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Runtime error 1 ms 604 KB Execution killed with signal 11
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 604 KB Execution killed with signal 7
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 504 KB Output is correct
2 Correct 1 ms 352 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 532 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Runtime error 1 ms 604 KB Execution killed with signal 11
7 Halted 0 ms 0 KB -