結果

問題 No.978 Fibonacci Convolution Easy
ユーザー stngstng
提出日時 2022-08-16 22:43:54
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 105 ms / 2,000 ms
コード長 356 bytes
コンパイル時間 240 ms
コンパイル使用メモリ 82,500 KB
実行使用メモリ 91,884 KB
最終ジャッジ日時 2024-04-14 16:19:51
合計ジャッジ時間 2,832 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 47 ms
61,904 KB
testcase_01 AC 70 ms
73,748 KB
testcase_02 AC 59 ms
66,436 KB
testcase_03 AC 101 ms
89,864 KB
testcase_04 AC 61 ms
68,520 KB
testcase_05 AC 51 ms
61,804 KB
testcase_06 AC 66 ms
70,520 KB
testcase_07 AC 83 ms
79,852 KB
testcase_08 AC 72 ms
73,896 KB
testcase_09 AC 89 ms
83,080 KB
testcase_10 AC 105 ms
91,492 KB
testcase_11 AC 65 ms
68,924 KB
testcase_12 AC 49 ms
61,716 KB
testcase_13 AC 65 ms
70,848 KB
testcase_14 AC 52 ms
63,364 KB
testcase_15 AC 70 ms
72,040 KB
testcase_16 AC 103 ms
91,884 KB
testcase_17 AC 103 ms
91,516 KB
testcase_18 AC 38 ms
52,616 KB
testcase_19 AC 38 ms
53,284 KB
testcase_20 AC 39 ms
52,640 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

if n == 1:
    print(0)
    exit()

a = [0]*(n)
a[0] = 0
a[1] = 1

for i in range(2,n):
    a[i] = p*a[i-1]+a[i-2]
    a[i] %= mod

rui = [0]*(n+1)
for i in range(n):
    rui[i+1] = rui[i]+a[i]
    rui[i+1] %= mod

ans = 0

for i in range(n):
    ans += a[i]*(rui[i+1]-rui[0]+mod)%mod
    ans %= mod
print(ans)
0