結果

問題 No.3006 ベイカーの問題
コンテスト
ユーザー flippergo
提出日時 2026-07-15 08:53:38
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
TLE  
実行時間 -
コード長 783 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 245 ms
コンパイル使用メモリ 95,728 KB
実行使用メモリ 97,852 KB
最終ジャッジ日時 2026-07-15 08:53:44
合計ジャッジ時間 6,132 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 5 TLE * 1 -- * 18
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

x1,y1,N = map(int,input().split())
MOD = 998244353
I = [[1,0],[0,1]]
def matmul(A,B):
    C = [[0,0],[0,0]]
    for i in range(2):
        for j in range(2):
            for k in range(2):
                C[i][j] = (C[i][j]+A[i][k]*B[k][j])%MOD
    return C
def matpow(A,n):
    if n==0:
        return I
    if n==1:
        return A
    if n%2==0:
        return matmul(matpow(A,n//2),matpow(A,n//2))
    return matmul(A,matpow(matpow(A,n//2),2))
A = [[x1,-5*y1],[y1,x1]]
if x1==1 and y1==0:
    print(N%MOD,0)
else:
    B = matpow(A,N)
    B = [[1-B[0][0],-B[0][1]],[-B[1][0],1-B[1][1]]]
    d = pow((1-x1)**2+5*y1**2,MOD-2,MOD)
    C = [[(1-x1)*d,-5*y1*d],[y1*d,(1-x1)*d]]
    B = matmul(B,C)
    s = (B[0][0]*x1+B[0][1]*y1)%MOD
    t = (B[1][0]*x1+B[1][1]*y1)%MOD
    print(s,t)
0