結果

問題 No.980 Fibonacci Convolution Hard
コンテスト
ユーザー tempura_pp
提出日時 2020-01-30 02:26:12
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 359 ms / 2,000 ms
コード長 269 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,335 ms
コンパイル使用メモリ 85,248 KB
実行使用メモリ 112,512 KB
最終ジャッジ日時 2026-04-06 06:33:27
合計ジャッジ時間 8,710 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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