結果

問題 No.1275 綺麗な式
ユーザー mkawa2mkawa2
提出日時 2021-09-02 01:32:20
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,326 bytes
コンパイル時間 483 ms
コンパイル使用メモリ 87,124 KB
実行使用メモリ 82,424 KB
最終ジャッジ日時 2023-08-19 08:46:46
合計ジャッジ時間 8,154 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
75,904 KB
testcase_01 AC 75 ms
71,508 KB
testcase_02 AC 73 ms
71,504 KB
testcase_03 AC 75 ms
71,352 KB
testcase_04 AC 75 ms
71,424 KB
testcase_05 AC 74 ms
71,488 KB
testcase_06 AC 75 ms
71,356 KB
testcase_07 AC 76 ms
71,192 KB
testcase_08 AC 75 ms
71,360 KB
testcase_09 AC 73 ms
71,328 KB
testcase_10 AC 75 ms
71,384 KB
testcase_11 AC 75 ms
71,352 KB
testcase_12 AC 76 ms
71,352 KB
testcase_13 AC 74 ms
71,376 KB
testcase_14 AC 73 ms
71,348 KB
testcase_15 AC 74 ms
71,296 KB
testcase_16 AC 75 ms
71,156 KB
testcase_17 AC 75 ms
71,296 KB
testcase_18 AC 75 ms
71,320 KB
testcase_19 AC 76 ms
71,148 KB
testcase_20 AC 77 ms
71,556 KB
testcase_21 AC 76 ms
71,312 KB
testcase_22 AC 76 ms
71,496 KB
testcase_23 AC 75 ms
71,440 KB
testcase_24 AC 76 ms
71,420 KB
testcase_25 AC 75 ms
71,436 KB
testcase_26 AC 74 ms
71,612 KB
testcase_27 AC 74 ms
71,464 KB
testcase_28 AC 74 ms
71,560 KB
testcase_29 AC 75 ms
71,504 KB
testcase_30 AC 73 ms
71,288 KB
testcase_31 AC 74 ms
71,288 KB
testcase_32 AC 73 ms
71,416 KB
testcase_33 AC 74 ms
71,384 KB
testcase_34 AC 73 ms
71,404 KB
testcase_35 AC 74 ms
71,120 KB
testcase_36 AC 74 ms
71,296 KB
testcase_37 AC 74 ms
71,508 KB
testcase_38 AC 77 ms
71,348 KB
testcase_39 AC 74 ms
71,296 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

sys.setrecursionlimit(200005)
int1 = lambda x: int(x)-1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
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 = 10**9
# md = 998244353
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, 1],
       [-s, 0]]

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