結果

問題 No.2632 Center of Three Points in Lp Norm
ユーザー maspymaspy
提出日時 2024-02-16 23:46:03
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 777 bytes
コンパイル時間 97 ms
コンパイル使用メモリ 11,904 KB
実行使用メモリ 73,652 KB
最終ジャッジ日時 2024-02-16 23:46:13
合計ジャッジ時間 8,116 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,333 ms
73,652 KB
testcase_01 AC 1,306 ms
66,848 KB
testcase_02 TLE -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
権限があれば一括ダウンロードができます

ソースコード

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":100000}
x_min = optimize.minimize(f, x0=[0, 0], method='Nelder-Mead', tol=1e-12, options=options)

print(*x_min.x)
0