結果

問題 No.2632 Center of Three Points in Lp Norm
ユーザー maspy
提出日時 2024-02-16 23:37:24
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 614 bytes
コンパイル時間 341 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 70,172 KB
最終ジャッジ日時 2024-09-28 22:41:20
合計ジャッジ時間 49,518 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3 WA * 1
other AC * 23 WA * 11
権限があれば一括ダウンロードができます

ソースコード

diff #

import scipy
from scipy import optimize

p = float(input())
x1, y1 = map(float, input().split())
x2, y2 = map(float, input().split())
x3, y3 = map(float, input().split())

def Lp(x,y):
    x = abs(x)
    y = abs(y)
    ma = max(x,y)
    if ma<1e-9:
        return 0
    x /= ma
    y /= ma
    x = x ** p
    y = y ** p
    return (x+y)**(1.0/p)*ma

def f(point):
    x, y = point
    d1 = Lp(x-x1,y-y1)
    d2 = Lp(x-x2,y-y2)
    d3 = Lp(x-x3,y-y3)
    return (d2 - d1) ** 2 + (d3 - d1) ** 2 + (d3 - d2) ** 2

options = {'maxiter': 10000}
x_min = optimize.minimize(f, x0=[0, 0], options=options)

print(*x_min.x)
0