結果

問題 No.980 Fibonacci Convolution Hard
ユーザー tempura_pptempura_pp
提出日時 2020-01-30 02:46:17
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 593 ms / 2,000 ms
コード長 339 bytes
コンパイル時間 237 ms
コンパイル使用メモリ 81,652 KB
実行使用メモリ 107,056 KB
最終ジャッジ日時 2023-10-17 13:25:37
合計ジャッジ時間 13,301 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 592 ms
107,056 KB
testcase_01 AC 592 ms
107,056 KB
testcase_02 AC 588 ms
107,056 KB
testcase_03 AC 589 ms
107,056 KB
testcase_04 AC 586 ms
107,052 KB
testcase_05 AC 589 ms
107,048 KB
testcase_06 AC 585 ms
107,052 KB
testcase_07 AC 591 ms
107,056 KB
testcase_08 AC 591 ms
107,052 KB
testcase_09 AC 591 ms
107,056 KB
testcase_10 AC 587 ms
107,052 KB
testcase_11 AC 588 ms
107,056 KB
testcase_12 AC 593 ms
107,052 KB
testcase_13 AC 588 ms
107,056 KB
testcase_14 AC 592 ms
107,056 KB
testcase_15 AC 591 ms
107,056 KB
testcase_16 AC 554 ms
107,052 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve():
    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])
solve()
0