結果

問題 No.2447 行列累乗根
ユーザー hitonanode
提出日時 2023-08-25 22:09:51
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 644 bytes
コンパイル時間 221 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 94,968 KB
最終ジャッジ日時 2024-12-24 09:01:24
合計ジャッジ時間 40,233 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 8 WA * 12 TLE * 8
権限があれば一括ダウンロードができます

ソースコード

diff #

import numpy as np

T = int(input())

def cb(a):
    if a >= 0:
        return pow(a, 1 / 3)
    else:
        return -pow(-a, 1 / 3)

for _ in range(T):
    a, b = map(float, input().split())
    c, d = map(float, input().split())
    A = np.array([[a, b], [c, d]])

    eig = np.linalg.eig(A)
    M = np.array([[eig.eigenvectors[0][0], eig.eigenvectors[1][0]], [eig.eigenvectors[0][1], eig.eigenvectors[1][1]]])

    e0 = cb(eig.eigenvalues[0])
    e1 = cb(eig.eigenvalues[1])

    B = M.T * np.diag([e0, e1]) * M
    print("{:1.5f}".format(B[0][0]), "{:1.5f}".format(B[0][1]))
    print("{:1.5f}".format(B[1][0]), "{:1.5f}".format(B[1][1]))
0