結果

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

ソースコード

diff #

from sys import stdin
import numpy as np

input = stdin.readline

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

T = int(input())

ret: list[str] = []

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

    eigval, eigvec = np.linalg.eigh(A)
    M = np.array([[eigvec[0][0], eigvec[0][1]], [eigvec[1][0], eigvec[1][1]]])

    e0 = cb(eigval[0])
    e1 = cb(eigval[1])

    B = M @ np.diag([e0, e1]) @ M.T
    ret.append("{:1.5f} {:1.5f}\n".format(B[0][0], B[0][1]))
    ret.append("{:1.5f} {:1.5f}\n".format(B[1][0], B[1][1]))


print("".join(ret))
0