結果

問題 No.978 Fibonacci Convolution Easy
ユーザー pluto77pluto77
提出日時 2020-02-02 09:47:11
言語 Python2
(2.7.18)
結果
AC  
実行時間 1,054 ms / 2,000 ms
コード長 220 bytes
コンパイル時間 378 ms
コンパイル使用メモリ 7,076 KB
実行使用メモリ 69,892 KB
最終ジャッジ日時 2023-10-19 01:12:01
合計ジャッジ時間 9,818 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 24 ms
7,008 KB
testcase_01 AC 418 ms
30,896 KB
testcase_02 AC 217 ms
18,820 KB
testcase_03 AC 1,013 ms
67,252 KB
testcase_04 AC 266 ms
21,724 KB
testcase_05 AC 66 ms
9,384 KB
testcase_06 AC 365 ms
27,728 KB
testcase_07 AC 653 ms
45,808 KB
testcase_08 AC 455 ms
33,536 KB
testcase_09 AC 754 ms
51,548 KB
testcase_10 AC 1,054 ms
69,628 KB
testcase_11 AC 306 ms
24,100 KB
testcase_12 AC 60 ms
9,120 KB
testcase_13 AC 358 ms
27,200 KB
testcase_14 AC 109 ms
12,024 KB
testcase_15 AC 403 ms
30,368 KB
testcase_16 AC 1,043 ms
69,892 KB
testcase_17 AC 1,046 ms
69,628 KB
testcase_18 AC 11 ms
6,392 KB
testcase_19 AC 12 ms
6,392 KB
testcase_20 AC 11 ms
6,392 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#yuki978
import sys
n,p=map(int,raw_input().split())
mod=10**9+7
a1,a2=0,1
res=1
temp=1
if n<=2:
 print(n-1)
 sys.exit()
for i in range(2,n):
 a1,a2=a2,(a2*p+a1)%mod
 temp=(temp+a2)%mod
 res=(res+a2*temp)%mod
print(res)
0