結果

問題 No.978 Fibonacci Convolution Easy
ユーザー H3PO4H3PO4
提出日時 2021-07-28 13:55:59
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 226 bytes
コンパイル時間 132 ms
コンパイル使用メモリ 10,744 KB
実行使用メモリ 86,592 KB
最終ジャッジ日時 2023-10-11 11:40:41
合計ジャッジ時間 10,563 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
8,916 KB
testcase_01 AC 418 ms
38,468 KB
testcase_02 AC 214 ms
23,360 KB
testcase_03 AC 991 ms
83,168 KB
testcase_04 AC 270 ms
27,320 KB
testcase_05 AC 68 ms
11,980 KB
testcase_06 AC 359 ms
34,292 KB
testcase_07 AC 676 ms
56,728 KB
testcase_08 AC 448 ms
41,732 KB
testcase_09 AC 748 ms
63,868 KB
testcase_10 AC 1,044 ms
86,376 KB
testcase_11 AC 308 ms
30,088 KB
testcase_12 AC 64 ms
11,544 KB
testcase_13 AC 363 ms
33,788 KB
testcase_14 AC 111 ms
15,076 KB
testcase_15 AC 399 ms
37,544 KB
testcase_16 AC 1,022 ms
86,592 KB
testcase_17 AC 1,031 ms
86,144 KB
testcase_18 RE -
testcase_19 AC 15 ms
7,916 KB
testcase_20 AC 15 ms
7,960 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, p = map(int, input().split())
MOD = 10 ** 9 + 7
inv2 = pow(2, MOD - 2, MOD)
a = [0] * N
a[1] = 1
for i in range(2, N):
    a[i] = (p * a[i - 1] + a[i - 2]) % MOD
print(((sum(a) ** 2 + sum(x ** 2 for x in a)) * inv2) % MOD)
0