結果

問題 No.980 Fibonacci Convolution Hard
ユーザー mkawa2mkawa2
提出日時 2023-02-21 18:02:45
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,237 bytes
コンパイル時間 450 ms
コンパイル使用メモリ 87,192 KB
実行使用メモリ 229,772 KB
最終ジャッジ日時 2023-09-29 09:29:35
合計ジャッジ時間 10,238 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 291 ms
229,216 KB
testcase_02 AC 291 ms
229,532 KB
testcase_03 AC 306 ms
228,724 KB
testcase_04 AC 285 ms
229,432 KB
testcase_05 AC 284 ms
229,652 KB
testcase_06 AC 279 ms
229,488 KB
testcase_07 AC 279 ms
229,344 KB
testcase_08 AC 284 ms
229,276 KB
testcase_09 AC 282 ms
229,700 KB
testcase_10 AC 282 ms
229,280 KB
testcase_11 AC 283 ms
229,352 KB
testcase_12 AC 279 ms
229,428 KB
testcase_13 AC 279 ms
229,436 KB
testcase_14 AC 281 ms
229,420 KB
testcase_15 AC 280 ms
229,136 KB
testcase_16 AC 250 ms
229,772 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

# sys.setrecursionlimit(200005)
int1 = lambda x: int(x)-1
pDB = lambda *x: print(*x, end="\n", file=sys.stderr)
p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr)
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()

# dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
inf = (1 << 63)-1
# inf = (1 << 31)-1
md = 10**9+7
# md = 998244353

#   f(x)=[a0, a1, a2, a3...]
# pxf(x)=[0 ,pa0,pa1,pa2,pa3...]
# x2f(x)=[0,   0, a0, a1, a2,a3...]
# (x2+px-1)f(x)=[-a0,-a1+pa0]
# (x4+2px3+(p^2-2)x2-2px+1)f^2(x)=[....]

p = II()
aa = [0, 1]
for _ in range(2):
    aa.append((aa[-2]+aa[-1]*p)%md)
ans = [0]*4
for i in range(4):
    for s in range(i+1):
        ans[i] += aa[s]*aa[i-s]

a, b = 2*p%md, (pow(p, 2, md)-2)%md
for _ in range(2000000):
    ans.append((-ans[-4]-a*ans[-3]-b*ans[-2]+a*ans[-1])%md)

for _ in range(II()):
    q = II()
    print(ans[q-2])
0