結果

問題 No.978 Fibonacci Convolution Easy
ユーザー NatsubiSoganNatsubiSogan
提出日時 2020-09-30 22:07:56
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 999 ms / 2,000 ms
コード長 250 bytes
コンパイル時間 160 ms
コンパイル使用メモリ 10,732 KB
実行使用メモリ 86,536 KB
最終ジャッジ日時 2023-09-20 17:56:05
合計ジャッジ時間 9,709 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
9,000 KB
testcase_01 AC 399 ms
38,784 KB
testcase_02 AC 210 ms
23,696 KB
testcase_03 AC 964 ms
83,452 KB
testcase_04 AC 252 ms
27,392 KB
testcase_05 AC 66 ms
12,208 KB
testcase_06 AC 348 ms
34,628 KB
testcase_07 AC 623 ms
56,836 KB
testcase_08 AC 440 ms
41,764 KB
testcase_09 AC 714 ms
64,088 KB
testcase_10 AC 996 ms
86,500 KB
testcase_11 AC 291 ms
30,460 KB
testcase_12 AC 61 ms
11,840 KB
testcase_13 AC 335 ms
34,180 KB
testcase_14 AC 105 ms
15,472 KB
testcase_15 AC 381 ms
37,812 KB
testcase_16 AC 999 ms
86,536 KB
testcase_17 AC 998 ms
86,328 KB
testcase_18 AC 16 ms
7,900 KB
testcase_19 AC 16 ms
7,848 KB
testcase_20 AC 16 ms
7,888 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, p = map(int, input().split())
fib = [0, 1]
for i in range(n - 2):
    fib.append((fib[-1] * p + fib[-2]) % (10 ** 9 + 7))
cnt = 0
for i in fib:
    cnt += i ** 2
print(((sum(fib) ** 2 + cnt) // 2) % (10 ** 9 + 7) if not (n == 1 and p == 1) else 0)
0