답안 #1027625

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1027625 2024-07-19T08:03:37 Z vjudge1 Fibonacci representations (CEOI18_fib) C++17
5 / 100
57 ms 8428 KB
#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";
  }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4188 KB Output is correct
2 Correct 2 ms 4188 KB Output is correct
3 Correct 2 ms 4232 KB Output is correct
4 Correct 2 ms 4332 KB Output is correct
5 Correct 3 ms 4188 KB Output is correct
6 Correct 3 ms 4188 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4188 KB Output is correct
2 Correct 2 ms 4188 KB Output is correct
3 Correct 2 ms 4232 KB Output is correct
4 Correct 2 ms 4332 KB Output is correct
5 Correct 3 ms 4188 KB Output is correct
6 Correct 3 ms 4188 KB Output is correct
7 Incorrect 2 ms 4188 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 5 ms 8428 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4188 KB Output is correct
2 Correct 2 ms 4188 KB Output is correct
3 Correct 2 ms 4232 KB Output is correct
4 Correct 2 ms 4332 KB Output is correct
5 Correct 3 ms 4188 KB Output is correct
6 Correct 3 ms 4188 KB Output is correct
7 Incorrect 2 ms 4188 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 57 ms 8276 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4188 KB Output is correct
2 Correct 2 ms 4188 KB Output is correct
3 Correct 2 ms 4232 KB Output is correct
4 Correct 2 ms 4332 KB Output is correct
5 Correct 3 ms 4188 KB Output is correct
6 Correct 3 ms 4188 KB Output is correct
7 Incorrect 2 ms 4188 KB Output isn't correct
8 Halted 0 ms 0 KB -