結果

問題 No.1275 綺麗な式
ユーザー mkawa2mkawa2
提出日時 2021-09-02 01:41:40
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 18 ms / 2,000 ms
コード長 1,362 bytes
コンパイル時間 601 ms
コンパイル使用メモリ 11,112 KB
実行使用メモリ 8,372 KB
最終ジャッジ日時 2023-08-19 08:56:01
合計ジャッジ時間 4,009 ms
ジャッジサーバーID
(参考情報)
judge13 / judge9
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
8,200 KB
testcase_01 AC 17 ms
8,060 KB
testcase_02 AC 17 ms
8,200 KB
testcase_03 AC 17 ms
8,044 KB
testcase_04 AC 17 ms
8,044 KB
testcase_05 AC 16 ms
8,224 KB
testcase_06 AC 17 ms
8,060 KB
testcase_07 AC 17 ms
8,064 KB
testcase_08 AC 17 ms
8,200 KB
testcase_09 AC 17 ms
8,060 KB
testcase_10 AC 16 ms
8,040 KB
testcase_11 AC 16 ms
8,120 KB
testcase_12 AC 17 ms
8,068 KB
testcase_13 AC 17 ms
8,068 KB
testcase_14 AC 18 ms
8,112 KB
testcase_15 AC 17 ms
8,124 KB
testcase_16 AC 16 ms
8,068 KB
testcase_17 AC 17 ms
8,216 KB
testcase_18 AC 17 ms
8,028 KB
testcase_19 AC 17 ms
8,036 KB
testcase_20 AC 17 ms
8,120 KB
testcase_21 AC 17 ms
8,064 KB
testcase_22 AC 17 ms
8,108 KB
testcase_23 AC 17 ms
8,168 KB
testcase_24 AC 17 ms
8,120 KB
testcase_25 AC 17 ms
8,216 KB
testcase_26 AC 16 ms
8,104 KB
testcase_27 AC 17 ms
8,208 KB
testcase_28 AC 17 ms
8,228 KB
testcase_29 AC 17 ms
8,060 KB
testcase_30 AC 16 ms
8,068 KB
testcase_31 AC 16 ms
8,116 KB
testcase_32 AC 16 ms
8,220 KB
testcase_33 AC 17 ms
8,064 KB
testcase_34 AC 17 ms
8,072 KB
testcase_35 AC 16 ms
8,064 KB
testcase_36 AC 16 ms
8,064 KB
testcase_37 AC 16 ms
8,064 KB
testcase_38 AC 17 ms
8,112 KB
testcase_39 AC 17 ms
8,108 KB
testcase_40 AC 17 ms
8,372 KB
testcase_41 AC 17 ms
8,172 KB
testcase_42 AC 16 ms
8,316 KB
testcase_43 AC 16 ms
8,316 KB
testcase_44 AC 17 ms
8,088 KB
testcase_45 AC 17 ms
8,112 KB
testcase_46 AC 16 ms
8,120 KB
testcase_47 AC 17 ms
8,120 KB
testcase_48 AC 18 ms
8,220 KB
testcase_49 AC 17 ms
8,200 KB
testcase_50 AC 17 ms
8,028 KB
testcase_51 AC 17 ms
8,064 KB
testcase_52 AC 17 ms
8,112 KB
testcase_53 AC 17 ms
8,064 KB
testcase_54 AC 17 ms
8,120 KB
testcase_55 AC 18 ms
8,108 KB
testcase_56 AC 17 ms
8,060 KB
testcase_57 AC 17 ms
8,068 KB
testcase_58 AC 17 ms
8,112 KB
testcase_59 AC 17 ms
8,092 KB
testcase_60 AC 17 ms
8,124 KB
testcase_61 AC 17 ms
8,100 KB
権限があれば一括ダウンロードができます

ソースコード

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()
if n==0:
    print(2)
    exit()

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

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