結果

問題 No.980 Fibonacci Convolution Hard
ユーザー lorent_kyopro
提出日時 2021-04-18 14:50:43
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 163 ms / 2,000 ms
コード長 694 bytes
コンパイル時間 2,328 ms
コンパイル使用メモリ 197,024 KB
最終ジャッジ日時 2025-01-20 21:38:38
ジャッジサーバーID
(参考情報)
judge5 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/modint>
using mint = atcoder::modint1000000007;

__attribute__((constructor))
void fast_io() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
}

int main() {
    long long p;
    std::cin >> p;
    std::vector<mint> b{0, 0, 1, 2*p}, c{2*p, 2 - p*p, -2*p, -1};
    int q;
    std::cin >> q;
    while (q--) {
        size_t x;
        std::cin >> x;
        x -= 2;
        while (b.size() <= x) {
            mint tmp = 0;
            for (size_t i = 0; i < c.size(); ++i) {
                tmp += c[i] * b[b.size() - 1 - i];
            }
            b.push_back(tmp);
        }
        std::cout << b[x].val() << '\n';
    }
}
0