結果

問題 No.1275 綺麗な式
ユーザー とりゐとりゐ
提出日時 2021-07-11 17:44:55
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 92 ms / 2,000 ms
コード長 1,155 bytes
コンパイル時間 312 ms
コンパイル使用メモリ 86,980 KB
実行使用メモリ 71,892 KB
最終ジャッジ日時 2023-09-14 20:16:26
合計ジャッジ時間 7,895 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 88 ms
71,868 KB
testcase_01 AC 91 ms
71,556 KB
testcase_02 AC 88 ms
71,564 KB
testcase_03 AC 87 ms
71,868 KB
testcase_04 AC 89 ms
71,736 KB
testcase_05 AC 90 ms
71,520 KB
testcase_06 AC 91 ms
71,736 KB
testcase_07 AC 89 ms
71,552 KB
testcase_08 AC 90 ms
71,336 KB
testcase_09 AC 91 ms
71,512 KB
testcase_10 AC 89 ms
71,736 KB
testcase_11 AC 88 ms
71,540 KB
testcase_12 AC 89 ms
71,736 KB
testcase_13 AC 90 ms
71,520 KB
testcase_14 AC 89 ms
71,500 KB
testcase_15 AC 90 ms
71,604 KB
testcase_16 AC 89 ms
71,736 KB
testcase_17 AC 88 ms
71,644 KB
testcase_18 AC 89 ms
71,344 KB
testcase_19 AC 90 ms
71,524 KB
testcase_20 AC 89 ms
71,560 KB
testcase_21 AC 87 ms
71,816 KB
testcase_22 AC 88 ms
71,548 KB
testcase_23 AC 90 ms
71,632 KB
testcase_24 AC 88 ms
71,868 KB
testcase_25 AC 91 ms
71,484 KB
testcase_26 AC 90 ms
71,664 KB
testcase_27 AC 90 ms
71,556 KB
testcase_28 AC 91 ms
71,656 KB
testcase_29 AC 90 ms
71,556 KB
testcase_30 AC 91 ms
71,280 KB
testcase_31 AC 91 ms
71,872 KB
testcase_32 AC 91 ms
71,688 KB
testcase_33 AC 90 ms
71,468 KB
testcase_34 AC 92 ms
71,528 KB
testcase_35 AC 91 ms
71,600 KB
testcase_36 AC 90 ms
71,708 KB
testcase_37 AC 92 ms
71,640 KB
testcase_38 AC 89 ms
71,612 KB
testcase_39 AC 89 ms
71,724 KB
testcase_40 AC 90 ms
71,572 KB
testcase_41 AC 91 ms
71,608 KB
testcase_42 AC 91 ms
71,856 KB
testcase_43 AC 89 ms
71,524 KB
testcase_44 AC 91 ms
71,404 KB
testcase_45 AC 91 ms
71,512 KB
testcase_46 AC 89 ms
71,616 KB
testcase_47 AC 90 ms
71,416 KB
testcase_48 AC 89 ms
71,864 KB
testcase_49 AC 91 ms
71,564 KB
testcase_50 AC 90 ms
71,556 KB
testcase_51 AC 89 ms
71,644 KB
testcase_52 AC 87 ms
71,776 KB
testcase_53 AC 89 ms
71,732 KB
testcase_54 AC 89 ms
71,752 KB
testcase_55 AC 87 ms
71,668 KB
testcase_56 AC 88 ms
71,892 KB
testcase_57 AC 88 ms
71,336 KB
testcase_58 AC 87 ms
71,516 KB
testcase_59 AC 87 ms
71,624 KB
testcase_60 AC 87 ms
71,628 KB
testcase_61 AC 86 ms
71,476 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import math
from collections import deque,Counter
#sys.setrecursionlimit(10**7)
int1=lambda x: int(x)-1

inp=lambda :int(input())
mi=lambda :map(int,input().split())
li=lambda :list(mi())
mi1=lambda :map(int1,input().split())
li1=lambda :list(mi1())
mis=lambda :map(str,input().split())
lis=lambda :list(mis())

from collections import defaultdict
"""
d=defaultdict(int) #初期値 0
d=defaultdict(lambda:1) #初期値 1
"""

mod=10**9+7
Mod=998244353
INF=10**18
ans=0

def matmul(A,B,mod): # A,B: 行列
    res = [[0]*len(B[0]) for _ in [None]*len(A)]
    for i, resi in enumerate(res):
        for k, aik in enumerate(A[i]):
            for j,bkj in enumerate(B[k]):
                resi[j] += aik*bkj
                resi[j] %= mod
    return res
 
def matpow(A,p,mod): #A^p mod M
    if p%2:
        return matmul(A, matpow(A,p-1,mod),mod)
    elif p > 0:
        b = matpow(A,p//2,mod)
        return matmul(b,b,mod)
    else:
        return [[int(i==j) for j in range(len(A))] for i in range(len(A))]

a,b=mi()
n=inp()
if n==0:
  print(2)
  exit()
x=[[2*a,b-a**2],[1,0]]
y=matpow(x,n-1,mod)
z=matmul(y,[[2*a],[2]],mod)
print(z[0][0]%mod)
0