結果

問題 No.978 Fibonacci Convolution Easy
ユーザー 双六双六
提出日時 2020-08-06 17:11:17
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 152 ms / 2,000 ms
コード長 613 bytes
コンパイル時間 934 ms
コンパイル使用メモリ 81,560 KB
実行使用メモリ 206,900 KB
最終ジャッジ日時 2023-10-21 06:15:14
合計ジャッジ時間 3,761 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
62,236 KB
testcase_01 AC 91 ms
117,600 KB
testcase_02 AC 70 ms
88,772 KB
testcase_03 AC 146 ms
206,256 KB
testcase_04 AC 77 ms
96,188 KB
testcase_05 AC 50 ms
68,240 KB
testcase_06 AC 87 ms
111,108 KB
testcase_07 AC 112 ms
151,876 KB
testcase_08 AC 95 ms
124,576 KB
testcase_09 AC 123 ms
163,516 KB
testcase_10 AC 146 ms
206,868 KB
testcase_11 AC 81 ms
100,772 KB
testcase_12 AC 51 ms
67,388 KB
testcase_13 AC 89 ms
111,016 KB
testcase_14 AC 59 ms
74,408 KB
testcase_15 AC 92 ms
117,416 KB
testcase_16 AC 152 ms
206,900 KB
testcase_17 AC 149 ms
206,848 KB
testcase_18 AC 39 ms
53,500 KB
testcase_19 AC 39 ms
53,500 KB
testcase_20 AC 40 ms
53,500 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys; input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**7)
from collections import defaultdict
con = 10 ** 9 + 7; INF = float("inf")

def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	N, P = getlist()
	Alist = [0, 0, 1]
	for i in range(N):
		Alist.append((Alist[-1] * P + Alist[-2]) % con)

	# print(Alist)

	ans = 0
	edge = 0
	for i in range(1, N + 1):
		edge += Alist[i]
		edge %= con
	ans = (edge ** 2) % con

	for i in range(1, N + 1):
		ans += Alist[i] ** 2
		ans %= con

	ans = ans * pow(2, con - 2, con)
	print(ans % con)

if __name__ == '__main__':
	main()
0