結果

問題 No.194 フィボナッチ数列の理解(1)
ユーザー mkawa2mkawa2
提出日時 2020-01-23 11:47:17
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
MLE  
実行時間 -
コード長 1,616 bytes
コンパイル時間 1,080 ms
コンパイル使用メモリ 10,772 KB
実行使用メモリ 814,768 KB
最終ジャッジ日時 2023-09-26 02:08:50
合計ジャッジ時間 5,677 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
8,024 KB
testcase_01 AC 16 ms
8,040 KB
testcase_02 AC 68 ms
8,060 KB
testcase_03 AC 27 ms
8,000 KB
testcase_04 AC 43 ms
8,040 KB
testcase_05 AC 39 ms
7,988 KB
testcase_06 AC 42 ms
8,156 KB
testcase_07 AC 53 ms
7,940 KB
testcase_08 AC 25 ms
8,084 KB
testcase_09 AC 47 ms
8,064 KB
testcase_10 AC 33 ms
8,080 KB
testcase_11 AC 33 ms
8,040 KB
testcase_12 AC 40 ms
8,044 KB
testcase_13 AC 30 ms
8,036 KB
testcase_14 AC 21 ms
8,032 KB
testcase_15 AC 56 ms
8,180 KB
testcase_16 AC 53 ms
8,000 KB
testcase_17 AC 32 ms
8,084 KB
testcase_18 AC 55 ms
7,996 KB
testcase_19 AC 65 ms
8,084 KB
testcase_20 AC 20 ms
8,180 KB
testcase_21 MLE -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

md = 10 ** 9 + 7
def main():
    def mm(aa, bb):
        res = [0] * (n * 2 - 1)
        for i, a in enumerate(aa):
            for j, b in enumerate(bb):
                res[i + j] = (res[i + j] + a * b) % md
        for i in range(n, 2 * n - 1):
            c = res[i]
            ffi = ff[i]
            for j in range(n):
                res[j] = (res[j] + c * ffi[j]) % md
        return res[:n]

    def v(x,base):
        bb = ff[x % bn][:]
        x //= bn
        while x:
            if x & 1: bb = mm(bb, base)
            base = mm(base, base)
            x >>= 1
        return sum(a * f % md for a, f in zip(bb, f0)) % md

    _, t = MI()
    aa = LI()

    n = len(aa) + 1
    coff = [-1] + [0] * (n - 2) + [2]
    f0 = [aa[0]]
    for x in range(1, n - 1):
        f0.append((f0[-1] + aa[x]) % md)
    f0.append(f0[-1] * 2 % md)
    ff = [[0] * n for _ in range(2 * n - 1)]
    for i in range(n): ff[i][i] = 1
    for i in range(n, 2 * n - 1):
        ffi = ff[i]
        for j, c in enumerate(coff, i - n):
            ffj = ff[j]
            for k in range(n): ffi[k] = (ffi[k] + c * ffj[k]) % md
    bn = 1 << (n - 1).bit_length()
    base = ff[bn]

    print((v(t - 1,base) - v(t - 2,base)) % md, v(t - 1,base))

main()
0