結果

問題 No.978 Fibonacci Convolution Easy
ユーザー ayaoniayaoni
提出日時 2020-12-09 17:42:36
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 640 bytes
コンパイル時間 1,631 ms
コンパイル使用メモリ 81,532 KB
実行使用メモリ 220,056 KB
最終ジャッジ日時 2023-10-19 05:01:58
合計ジャッジ時間 4,915 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 48 ms
64,448 KB
testcase_01 AC 129 ms
130,764 KB
testcase_02 AC 93 ms
102,004 KB
testcase_03 AC 256 ms
219,276 KB
testcase_04 AC 135 ms
109,328 KB
testcase_05 AC 58 ms
78,644 KB
testcase_06 AC 119 ms
124,300 KB
testcase_07 AC 175 ms
165,016 KB
testcase_08 AC 136 ms
137,824 KB
testcase_09 AC 192 ms
176,632 KB
testcase_10 AC 254 ms
219,928 KB
testcase_11 AC 160 ms
114,012 KB
testcase_12 AC 59 ms
75,744 KB
testcase_13 AC 121 ms
124,036 KB
testcase_14 AC 73 ms
87,620 KB
testcase_15 AC 129 ms
130,500 KB
testcase_16 AC 258 ms
220,056 KB
testcase_17 AC 255 ms
219,996 KB
testcase_18 WA -
testcase_19 AC 41 ms
53,400 KB
testcase_20 AC 40 ms
53,400 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def LS2(): return list(sys.stdin.readline().rstrip())


N,p = MI()
mod = 10**9+7

A = [0,0,1]
for _ in range(N-2):
    A.append((p*A[-1]+A[-2]) % mod)

x = sum(A) % mod
y = sum(a**2 for a in A) % mod

ans = (x**2+y)*(mod+1)//2
print(ans % mod)
0