제출 #1175023

#제출 시각아이디문제언어결과실행 시간메모리
1175023SulAFibonacci representations (CEOI18_fib)C++20
5 / 100
2 ms840 KiB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define popcount __builtin_popcountll
#define all(a) (a).begin(), (a).end()
using namespace std;
using namespace __gnu_pbds;
template<typename T> using ordered_set = tree<T, null_type, less<>, rb_tree_tag, tree_order_statistics_node_update>;

const int A = 987*100, MOD = 1e9+7;
int f[40], dp[A + 1];

void add(int x) {
    for (int j = A; j >= x; j--) {
        dp[j] += dp[j-x];
        if (dp[j] >= MOD) dp[j] -= MOD;
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    dp[0] = 1;
    f[0] = 1;
    f[1] = 2;
    for (int i = 2; i < 40; i++)
        f[i] = f[i-1] + f[i-2];
    for (int x : f) add(x);
    int n; cin >> n;
    int sum = 0;
    while (n--) {
        int x; cin >> x;
        sum += f[--x];
        cout << dp[sum] << "\n";
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...