結果

問題 No.978 Fibonacci Convolution Easy
ユーザー takakintakakin
提出日時 2020-05-24 16:32:22
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 362 bytes
コンパイル時間 91 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 167,572 KB
最終ジャッジ日時 2024-04-20 01:59:00
合計ジャッジ時間 21,819 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 60 ms
12,544 KB
testcase_01 AC 992 ms
71,828 KB
testcase_02 AC 512 ms
41,492 KB
testcase_03 TLE -
testcase_04 AC 632 ms
49,044 KB
testcase_05 AC 157 ms
18,704 KB
testcase_06 AC 860 ms
63,336 KB
testcase_07 AC 1,542 ms
108,048 KB
testcase_08 AC 1,073 ms
77,844 KB
testcase_09 AC 1,757 ms
122,516 KB
testcase_10 TLE -
testcase_11 AC 719 ms
55,188 KB
testcase_12 AC 138 ms
17,788 KB
testcase_13 AC 869 ms
62,488 KB
testcase_14 AC 241 ms
25,364 KB
testcase_15 AC 964 ms
70,032 KB
testcase_16 TLE -
testcase_17 TLE -
testcase_18 AC 30 ms
10,624 KB
testcase_19 AC 29 ms
10,624 KB
testcase_20 AC 24 ms
10,752 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input=lambda: sys.stdin.readline().rstrip()
n,p=map(int,input().split())
mod=10**9+7
if n==1:
  print(0)
elif n==2:
  print(1)
else:
  A=[0,1]
  B=[0,1]
  for _ in range(n-2):
    A.append((p*A[-1]+A[-2])%mod)
    B.append((A[-1]**2)%mod)
  a,b=0,0
  for i in range(n):
    a=(a+A[i])%mod
    b=(b+B[i])%mod
  print(((a**2+b)*pow(2,mod-2,mod))%mod)
  
0