結果

問題 No.3226 2×2行列累乗
コンテスト
ユーザー flippergo
提出日時 2026-03-11 08:39:24
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
TLE  
実行時間 -
コード長 628 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 258 ms
コンパイル使用メモリ 85,068 KB
実行使用メモリ 148,876 KB
最終ジャッジ日時 2026-03-11 08:40:26
合計ジャッジ時間 57,226 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 9 TLE * 18
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

a,b = map(int,input().split())
c,d = map(int,input().split())
s,t = map(int,input().split())
N,K = map(int,input().split())
def matprod(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])%K
    return C
def matpow(A,n):
    if n==0:
        return [[1,0],[0,1]]
    if n==1:
        return A
    if n%2==0:
        return matprod(matpow(A,n//2),matpow(A,n//2))
    else:
        return matprod(A, matpow(A, n-1))
M = [[a,b],[c,d]]
M = matpow(M,N)
r = (M[0][0]*s + M[0][1]*t)%K
u = (M[1][0]*s + M[1][1]*t)%K
print(r,u)
0