結果

問題 No.980 Fibonacci Convolution Hard
コンテスト
ユーザー lorent_kyopro
提出日時 2021-04-18 14:50:43
言語 C++17
(gcc 15.2.0 + boost 1.90.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 63 ms / 2,000 ms
コード長 694 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,439 ms
コンパイル使用メモリ 215,404 KB
実行使用メモリ 11,772 KB
最終ジャッジ日時 2026-06-19 20:51:35
合計ジャッジ時間 8,492 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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