結果

問題 No.978 Fibonacci Convolution Easy
ユーザー AEnAEn
提出日時 2022-05-19 09:54:31
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 191 ms / 2,000 ms
コード長 248 bytes
コンパイル時間 235 ms
コンパイル使用メモリ 81,856 KB
実行使用メモリ 215,520 KB
最終ジャッジ日時 2023-10-17 18:06:20
合計ジャッジ時間 3,603 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
62,532 KB
testcase_01 AC 109 ms
129,128 KB
testcase_02 AC 83 ms
104,260 KB
testcase_03 AC 189 ms
214,992 KB
testcase_04 AC 89 ms
108,416 KB
testcase_05 AC 52 ms
74,500 KB
testcase_06 AC 102 ms
122,928 KB
testcase_07 AC 142 ms
162,368 KB
testcase_08 AC 116 ms
135,856 KB
testcase_09 AC 156 ms
184,656 KB
testcase_10 AC 190 ms
215,520 KB
testcase_11 AC 97 ms
117,256 KB
testcase_12 AC 52 ms
73,676 KB
testcase_13 AC 102 ms
122,928 KB
testcase_14 AC 65 ms
87,236 KB
testcase_15 AC 109 ms
128,864 KB
testcase_16 AC 190 ms
215,520 KB
testcase_17 AC 191 ms
215,520 KB
testcase_18 AC 37 ms
53,516 KB
testcase_19 AC 37 ms
53,516 KB
testcase_20 AC 37 ms
53,516 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, p = map(int, input().split())
a = [0, 1]
mod = 10**9+7
for i in range(2, N):
    a.append((p*a[-1]+a[-2])%mod)
s = 0
ss = 0
for i in range(N):
    s += a[i]
    s %= mod
    ss += a[i]**2
    s %= mod
print(((s**2-ss)*pow(2, mod-2, mod)+ss)%mod)
0