結果

問題 No.3006 ベイカーの問題
コンテスト
ユーザー flippergo
提出日時 2026-07-15 09:08:17
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
WA  
実行時間 -
コード長 782 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 231 ms
コンパイル使用メモリ 96,108 KB
実行使用メモリ 78,848 KB
最終ジャッジ日時 2026-07-15 09:08:21
合計ジャッジ時間 3,432 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22 WA * 2
権限があれば一括ダウンロードができます

ソースコード

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
    half = matpow(A,n//2)
    if n%2==0:
        return matmul(half,half)
    return matmul(A,matmul(half,half))
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