結果

問題 No.978 Fibonacci Convolution Easy
ユーザー mlihua09mlihua09
提出日時 2020-09-21 11:20:07
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 201 ms / 2,000 ms
コード長 311 bytes
コンパイル時間 2,604 ms
コンパイル使用メモリ 86,504 KB
実行使用メモリ 161,652 KB
最終ジャッジ日時 2023-09-06 17:02:54
合計ジャッジ時間 5,129 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 84 ms
76,920 KB
testcase_01 AC 143 ms
118,100 KB
testcase_02 AC 112 ms
108,320 KB
testcase_03 AC 196 ms
151,256 KB
testcase_04 AC 117 ms
113,276 KB
testcase_05 AC 86 ms
83,316 KB
testcase_06 AC 131 ms
118,168 KB
testcase_07 AC 161 ms
137,716 KB
testcase_08 AC 145 ms
118,064 KB
testcase_09 AC 174 ms
161,652 KB
testcase_10 AC 199 ms
150,980 KB
testcase_11 AC 124 ms
118,116 KB
testcase_12 AC 87 ms
82,232 KB
testcase_13 AC 130 ms
118,068 KB
testcase_14 AC 97 ms
90,100 KB
testcase_15 AC 135 ms
117,952 KB
testcase_16 AC 200 ms
151,008 KB
testcase_17 AC 201 ms
150,960 KB
testcase_18 AC 72 ms
71,104 KB
testcase_19 AC 72 ms
71,380 KB
testcase_20 AC 73 ms
71,072 KB
権限があれば一括ダウンロードができます

ソースコード

diff #


N, p = map(int, input().split())
mod = 10 ** 9 + 7

A = [0, 1]

for i in range(N - 2):
    
    A += [(A[-1] * p + A[-2]) % mod]
    
a = A.copy()

for i in range(1, N):
    a[i] += a[i - 1]
    a[i] %= mod
    
ans = 0

for i in range(N):
    
    ans += A[i] * a[i] % mod
    ans %= mod
    
    
print(ans)
0