結果

問題 No.980 Fibonacci Convolution Hard
ユーザー ytftytft
提出日時 2021-04-17 15:00:30
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 360 ms / 2,000 ms
コード長 444 bytes
コンパイル時間 1,486 ms
コンパイル使用メモリ 165,648 KB
実行使用メモリ 34,516 KB
最終ジャッジ日時 2023-09-17 00:08:53
合計ジャッジ時間 9,750 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 343 ms
34,512 KB
testcase_01 AC 340 ms
34,516 KB
testcase_02 AC 338 ms
34,392 KB
testcase_03 AC 339 ms
34,376 KB
testcase_04 AC 330 ms
34,336 KB
testcase_05 AC 334 ms
34,248 KB
testcase_06 AC 333 ms
34,392 KB
testcase_07 AC 339 ms
34,488 KB
testcase_08 AC 346 ms
34,240 KB
testcase_09 AC 328 ms
34,412 KB
testcase_10 AC 332 ms
34,332 KB
testcase_11 AC 336 ms
34,312 KB
testcase_12 AC 345 ms
34,412 KB
testcase_13 AC 341 ms
34,372 KB
testcase_14 AC 360 ms
34,408 KB
testcase_15 AC 340 ms
34,400 KB
testcase_16 AC 313 ms
34,212 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
    long long Q,p;
    cin>>p>>Q;
    long long MOD=1000000007;
    int rang=2000000;
    vector<long long> a(rang),b(rang);
    a[1]=1;
    for(int i=2;i<rang;i++){
        a[i]=(a[i-1]*p+a[i-2])%MOD;
    }
    for(int i=2;i<rang;i++){
        b[i]=(p*b[i-1]+b[i-2]+a[i-2])%MOD;
    }
    int input;
    for(int i=0;i<Q;i++){
        cin>>input;
        cout<<b[input-1]<<endl;
    }
}
0