結果

問題 No.2447 行列累乗根
ユーザー 👑 hitonanodehitonanode
提出日時 2023-08-25 23:06:10
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 645 bytes
コンパイル時間 277 ms
コンパイル使用メモリ 10,768 KB
実行使用メモリ 34,872 KB
最終ジャッジ日時 2023-08-25 23:06:20
合計ジャッジ時間 8,809 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 134 ms
30,228 KB
testcase_01 AC 137 ms
31,868 KB
testcase_02 AC 131 ms
30,460 KB
testcase_03 AC 130 ms
30,332 KB
testcase_04 AC 130 ms
32,120 KB
testcase_05 AC 130 ms
30,392 KB
testcase_06 AC 131 ms
30,336 KB
testcase_07 AC 133 ms
32,040 KB
testcase_08 AC 133 ms
30,428 KB
testcase_09 AC 132 ms
30,392 KB
testcase_10 AC 130 ms
31,908 KB
testcase_11 AC 131 ms
30,340 KB
testcase_12 AC 131 ms
30,564 KB
testcase_13 AC 130 ms
30,300 KB
testcase_14 AC 129 ms
30,312 KB
testcase_15 AC 137 ms
32,060 KB
testcase_16 AC 129 ms
30,284 KB
testcase_17 AC 134 ms
30,344 KB
testcase_18 AC 169 ms
32,080 KB
testcase_19 AC 489 ms
30,424 KB
testcase_20 TLE -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
権限があれば一括ダウンロードができます

ソースコード

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())


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
    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