結果

問題 No.978 Fibonacci Convolution Easy
ユーザー tyawanmusityawanmusi
提出日時 2020-01-31 21:40:38
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,860 ms / 2,000 ms
コード長 209 bytes
コンパイル時間 183 ms
コンパイル使用メモリ 11,840 KB
実行使用メモリ 10,164 KB
最終ジャッジ日時 2023-10-19 00:58:56
合計ジャッジ時間 16,104 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 49 ms
10,164 KB
testcase_01 AC 728 ms
10,164 KB
testcase_02 AC 377 ms
10,164 KB
testcase_03 AC 1,715 ms
10,164 KB
testcase_04 AC 462 ms
10,164 KB
testcase_05 AC 121 ms
10,164 KB
testcase_06 AC 631 ms
10,164 KB
testcase_07 AC 1,155 ms
10,164 KB
testcase_08 AC 800 ms
10,164 KB
testcase_09 AC 1,300 ms
10,164 KB
testcase_10 AC 1,860 ms
10,164 KB
testcase_11 AC 528 ms
10,164 KB
testcase_12 AC 111 ms
10,164 KB
testcase_13 AC 618 ms
10,164 KB
testcase_14 AC 197 ms
10,164 KB
testcase_15 AC 714 ms
10,164 KB
testcase_16 AC 1,826 ms
10,164 KB
testcase_17 AC 1,787 ms
10,164 KB
testcase_18 AC 29 ms
10,164 KB
testcase_19 AC 29 ms
10,164 KB
testcase_20 AC 31 ms
10,164 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod=10**9+7
n,p=map(int,input().split())
if n==1:print(0);exit()
if n==2:print(1);exit()
s=1
a0,a1=0,1
ans=1
for i in range(2,n):
  a0,a1=a1,a0+p*a1
  a1%=mod
  s+=a1
  s%=mod
  ans+=s*a1
  ans%=mod
print(ans)
0