結果

問題 No.980 Fibonacci Convolution Hard
ユーザー tempura_pptempura_pp
提出日時 2020-01-30 02:26:12
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 576 ms / 2,000 ms
コード長 269 bytes
コンパイル時間 1,911 ms
コンパイル使用メモリ 81,308 KB
実行使用メモリ 106,936 KB
最終ジャッジ日時 2023-10-17 13:24:59
合計ジャッジ時間 13,466 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 564 ms
106,936 KB
testcase_01 AC 576 ms
106,936 KB
testcase_02 AC 570 ms
106,936 KB
testcase_03 AC 566 ms
106,936 KB
testcase_04 AC 568 ms
106,936 KB
testcase_05 AC 572 ms
106,936 KB
testcase_06 AC 573 ms
106,936 KB
testcase_07 AC 574 ms
106,936 KB
testcase_08 AC 571 ms
106,936 KB
testcase_09 AC 575 ms
106,936 KB
testcase_10 AC 575 ms
106,936 KB
testcase_11 AC 574 ms
106,936 KB
testcase_12 AC 569 ms
106,936 KB
testcase_13 AC 566 ms
106,936 KB
testcase_14 AC 564 ms
106,936 KB
testcase_15 AC 569 ms
106,936 KB
testcase_16 AC 532 ms
106,936 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

M = 2000001;
mod = 10**9+7 ;
p = int(input())
ans = [0]*M
a = [0]*M
a[2] = 1
for i in range(3,M) : 
    ans[i] = (p * ans[i-1] + ans[i-2] + a[i-2]) % mod
    a[i] = (p * a[i-1] + a[i-2]) % mod
q = int(input())
for i in range(q) : 
    x = int(input())
    print(ans[x])
0