結果

問題 No.978 Fibonacci Convolution Easy
ユーザー Navier_BoltzmannNavier_Boltzmann
提出日時 2023-01-18 07:00:00
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 394 bytes
コンパイル時間 902 ms
コンパイル使用メモリ 87,096 KB
実行使用メモリ 93,280 KB
最終ジャッジ日時 2023-09-02 03:36:35
合計ジャッジ時間 5,295 ms
ジャッジサーバーID
(参考情報)
judge11 / judge16
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 116 ms
77,792 KB
testcase_01 AC 120 ms
83,660 KB
testcase_02 AC 114 ms
80,924 KB
testcase_03 AC 134 ms
92,596 KB
testcase_04 AC 117 ms
81,500 KB
testcase_05 AC 111 ms
78,392 KB
testcase_06 AC 118 ms
83,064 KB
testcase_07 AC 124 ms
87,488 KB
testcase_08 AC 119 ms
84,472 KB
testcase_09 AC 127 ms
89,044 KB
testcase_10 AC 136 ms
93,280 KB
testcase_11 AC 117 ms
82,260 KB
testcase_12 AC 109 ms
78,400 KB
testcase_13 AC 116 ms
82,976 KB
testcase_14 AC 110 ms
79,360 KB
testcase_15 AC 120 ms
83,812 KB
testcase_16 AC 134 ms
93,248 KB
testcase_17 AC 134 ms
93,156 KB
testcase_18 RE -
testcase_19 AC 105 ms
73,204 KB
testcase_20 AC 105 ms
73,000 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import *
from itertools import *
from functools import *
from heapq import *
import sys,math
input = sys.stdin.readline

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

a = [0]*(N+1)
a[2]=1
ans = 0
S = 0
if N==1:
    print(0)
    exit()
ans = 1
S = 1
for i in range(3,N+1):
    a[i]=(p*a[i-1]+a[i-2])%mod
    S += a[i]
    ans += S*a[i]
    ans %= mod
    S %= mod
print(ans)

0