結果

問題 No.980 Fibonacci Convolution Hard
ユーザー りあんりあん
提出日時 2020-01-31 22:15:41
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 83 ms / 2,000 ms
コード長 539 bytes
コンパイル時間 3,805 ms
コンパイル使用メモリ 202,788 KB
実行使用メモリ 34,448 KB
最終ジャッジ日時 2023-10-17 13:31:59
合計ジャッジ時間 6,052 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
34,448 KB
testcase_01 AC 82 ms
34,448 KB
testcase_02 AC 83 ms
34,448 KB
testcase_03 AC 82 ms
34,448 KB
testcase_04 AC 83 ms
34,448 KB
testcase_05 AC 82 ms
34,448 KB
testcase_06 AC 83 ms
34,448 KB
testcase_07 AC 83 ms
34,448 KB
testcase_08 AC 82 ms
34,448 KB
testcase_09 AC 83 ms
34,448 KB
testcase_10 AC 82 ms
34,448 KB
testcase_11 AC 83 ms
34,448 KB
testcase_12 AC 82 ms
34,448 KB
testcase_13 AC 83 ms
34,448 KB
testcase_14 AC 83 ms
34,448 KB
testcase_15 AC 83 ms
34,448 KB
testcase_16 AC 63 ms
34,448 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
const int M = 1000000007;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int p, q;
    cin >> p >> q;
    int n = 2000010;
    vector<long long> a(n), s(n);
    a[1] = 1;
    for (int i = 2; i < n; i++) {
        a[i] = (p * a[i - 1] + a[i - 2]) % M;
        s[i] = ((p * s[i - 1] + s[i - 2] + a[i - 1]) % M + M) % M;
    }
    for (int i = 0; i < q; i++) {
        int x;
        cin >> x;
        cout << s[x - 2] << '\n';
    }
    return 0;
}
0