結果

問題 No.980 Fibonacci Convolution Hard
ユーザー lorent_kyoprolorent_kyopro
提出日時 2021-04-18 14:50:43
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 88 ms / 2,000 ms
コード長 694 bytes
コンパイル時間 2,423 ms
コンパイル使用メモリ 202,460 KB
実行使用メモリ 13,228 KB
最終ジャッジ日時 2023-09-17 07:42:18
合計ジャッジ時間 8,764 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 84 ms
12,336 KB
testcase_01 AC 84 ms
11,840 KB
testcase_02 AC 86 ms
11,744 KB
testcase_03 AC 84 ms
12,712 KB
testcase_04 AC 84 ms
11,420 KB
testcase_05 AC 85 ms
11,792 KB
testcase_06 AC 85 ms
12,320 KB
testcase_07 AC 84 ms
12,172 KB
testcase_08 AC 84 ms
11,664 KB
testcase_09 AC 86 ms
12,808 KB
testcase_10 AC 88 ms
12,096 KB
testcase_11 AC 86 ms
13,228 KB
testcase_12 AC 86 ms
12,804 KB
testcase_13 AC 86 ms
11,728 KB
testcase_14 AC 86 ms
13,004 KB
testcase_15 AC 86 ms
11,808 KB
testcase_16 AC 34 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

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