結果

問題 No.2632 Center of Three Points in Lp Norm
ユーザー maspymaspy
提出日時 2024-02-16 23:51:59
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 776 bytes
コンパイル時間 145 ms
コンパイル使用メモリ 11,904 KB
実行使用メモリ 66,872 KB
最終ジャッジ日時 2024-02-16 23:52:55
合計ジャッジ時間 44,230 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,087 ms
66,868 KB
testcase_01 AC 1,065 ms
66,848 KB
testcase_02 AC 1,093 ms
66,848 KB
testcase_03 AC 1,108 ms
66,836 KB
testcase_04 AC 1,063 ms
66,868 KB
testcase_05 AC 1,074 ms
66,836 KB
testcase_06 AC 1,068 ms
66,856 KB
testcase_07 AC 1,065 ms
66,852 KB
testcase_08 AC 1,058 ms
66,836 KB
testcase_09 AC 1,082 ms
66,836 KB
testcase_10 AC 1,102 ms
66,836 KB
testcase_11 WA -
testcase_12 AC 1,067 ms
66,848 KB
testcase_13 AC 1,061 ms
66,836 KB
testcase_14 AC 1,069 ms
66,836 KB
testcase_15 AC 1,091 ms
66,836 KB
testcase_16 AC 1,072 ms
66,836 KB
testcase_17 AC 1,020 ms
66,848 KB
testcase_18 AC 1,059 ms
66,848 KB
testcase_19 AC 1,039 ms
66,836 KB
testcase_20 AC 1,061 ms
66,836 KB
testcase_21 AC 1,063 ms
66,848 KB
testcase_22 AC 1,052 ms
66,856 KB
testcase_23 AC 1,032 ms
66,836 KB
testcase_24 AC 1,100 ms
66,848 KB
testcase_25 WA -
testcase_26 AC 1,081 ms
66,836 KB
testcase_27 AC 1,058 ms
66,848 KB
testcase_28 AC 1,106 ms
66,848 KB
testcase_29 AC 1,087 ms
66,848 KB
testcase_30 AC 1,092 ms
66,860 KB
testcase_31 AC 1,028 ms
66,836 KB
testcase_32 AC 1,052 ms
66,868 KB
testcase_33 WA -
testcase_34 AC 1,034 ms
66,836 KB
testcase_35 AC 1,072 ms
66,848 KB
testcase_36 AC 1,011 ms
66,856 KB
testcase_37 AC 1,078 ms
66,852 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import numpy as np
from scipy import optimize

# 高精度の浮動小数点数を使用する
p = np.float64(input())
points = []
for _ in range(3):
    x, y = map(np.float64, input().split())
    points.append((x, y))

def Lp(x, y):
    x = np.abs(x)
    y = np.abs(y)
    ma = max(x, y)
    if ma < 1e-9:
        return np.float64(1e-9)  # 非常に小さな値を返す
    x /= ma
    y /= ma
    x = x ** p
    y = y ** p
    return (x + y) ** (1.0 / p) * ma

def f(point):
    x, y = point
    distances = [Lp(x - px, y - py) for px, py in points]
    d1, d2, d3 = distances
    return (d2 - d1) ** 2 + (d3 - d1) ** 2 + (d3 - d2) ** 2

options={"maxiter":10000}
x_min = optimize.minimize(f, x0=[0, 0], method='Nelder-Mead', tol=1e-10, options=options)

print(*x_min.x)
0