結果
| 問題 | No.3006 ベイカーの問題 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-07-15 08:57:30 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 796 bytes |
| 記録 | |
| コンパイル時間 | 240 ms |
| コンパイル使用メモリ | 96,112 KB |
| 実行使用メモリ | 91,776 KB |
| 最終ジャッジ日時 | 2026-07-15 08:57:38 |
| 合計ジャッジ時間 | 6,487 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 4 TLE * 1 -- * 19 |
ソースコード
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,matmul(matpow(A,n//2),matpow(A,n//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)