結果

問題 No.1275 綺麗な式
ユーザー mkawa2mkawa2
提出日時 2021-09-02 01:38:42
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 847 bytes
コンパイル時間 608 ms
コンパイル使用メモリ 86,816 KB
実行使用メモリ 82,044 KB
最終ジャッジ日時 2023-08-19 08:53:20
合計ジャッジ時間 9,118 ms
ジャッジサーバーID
(参考情報)
judge14 / judge10
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
78,352 KB
testcase_01 AC 73 ms
71,232 KB
testcase_02 AC 73 ms
71,236 KB
testcase_03 AC 73 ms
70,968 KB
testcase_04 AC 72 ms
71,252 KB
testcase_05 AC 72 ms
71,004 KB
testcase_06 AC 74 ms
70,976 KB
testcase_07 AC 70 ms
71,192 KB
testcase_08 AC 73 ms
71,200 KB
testcase_09 AC 72 ms
71,016 KB
testcase_10 AC 74 ms
71,300 KB
testcase_11 AC 74 ms
71,036 KB
testcase_12 AC 74 ms
71,088 KB
testcase_13 AC 72 ms
71,008 KB
testcase_14 AC 72 ms
71,236 KB
testcase_15 AC 73 ms
71,284 KB
testcase_16 AC 74 ms
71,236 KB
testcase_17 AC 73 ms
71,036 KB
testcase_18 AC 71 ms
71,236 KB
testcase_19 AC 70 ms
71,140 KB
testcase_20 AC 70 ms
71,008 KB
testcase_21 AC 71 ms
71,016 KB
testcase_22 AC 71 ms
71,232 KB
testcase_23 AC 72 ms
71,168 KB
testcase_24 AC 71 ms
70,836 KB
testcase_25 AC 72 ms
71,288 KB
testcase_26 AC 71 ms
71,232 KB
testcase_27 AC 71 ms
70,836 KB
testcase_28 AC 71 ms
71,120 KB
testcase_29 AC 71 ms
71,040 KB
testcase_30 AC 70 ms
70,772 KB
testcase_31 AC 70 ms
71,128 KB
testcase_32 AC 70 ms
70,784 KB
testcase_33 AC 72 ms
71,292 KB
testcase_34 AC 74 ms
71,248 KB
testcase_35 AC 73 ms
71,148 KB
testcase_36 AC 72 ms
70,780 KB
testcase_37 AC 74 ms
71,240 KB
testcase_38 AC 73 ms
70,744 KB
testcase_39 AC 74 ms
71,236 KB
testcase_40 TLE -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
testcase_54 -- -
testcase_55 -- -
testcase_56 -- -
testcase_57 -- -
testcase_58 -- -
testcase_59 -- -
testcase_60 -- -
testcase_61 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
md = 10**9+7

def dot(aa, bb):
    h = len(aa)
    w = len(bb[0])
    res = [[0]*w for _ in range(h)]
    for i, row in enumerate(aa):
        for j, col in enumerate(zip(*bb)):
            v = 0
            # for a, b in zip(row, col): v += a*b
            # res[i][j] = v%md
            for a, b in zip(row, col): v += a*b%md
            res[i][j] = v%md
    return res

def matpow(mat, e):
    n = len(mat)
    res = [[1 if i == j else 0 for j in range(n)] for i in range(n)]
    while e:
        if e & 1: res = dot(res, mat)
        mat = dot(mat, mat)
        e >>= 1
    return res

a, b = LI()
s = (-a**2+b)%md
n = II()

mat = [[2*a%md, 1],
       [s, 0]]

cc = matpow(mat, n-1)
ans = dot([[2*a, 2]], cc)
print(ans[0][0])
0