結果

問題 No.980 Fibonacci Convolution Hard
ユーザー tempura_pp
提出日時 2020-01-30 02:26:12
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 546 ms / 2,000 ms
コード長 269 bytes
コンパイル時間 621 ms
コンパイル使用メモリ 82,196 KB
実行使用メモリ 107,736 KB
最終ジャッジ日時 2024-09-17 11:24:20
合計ジャッジ時間 11,692 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

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