結果
| 問題 | No.2632 Center of Three Points in Lp Norm | 
| コンテスト | |
| ユーザー | 👑  tatyam | 
| 提出日時 | 2024-02-12 07:49:52 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 876 bytes | 
| コンパイル時間 | 141 ms | 
| コンパイル使用メモリ | 82,496 KB | 
| 実行使用メモリ | 80,468 KB | 
| 最終ジャッジ日時 | 2024-09-28 17:52:56 | 
| 合計ジャッジ時間 | 10,244 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 WA * 1 | 
| other | AC * 23 WA * 11 | 
ソースコード
import random
import math
def norm(x: float, y: float) -> float:
    x = abs(x)
    y = abs(y)
    if x > y:
        x, y = y, x
    if y == 0.0:
        return 0.0
    x /= y
    return pow(1.0 + pow(x, p), 1 / p) * y
def dist(a, b):
    return norm(a[0] - b[0], a[1] - b[1])
get = lambda: list(map(float, input().split()))
p = float(input())
a = get()
b = get()
c = get()
def f(o) -> float:
    D = [dist(a, o), dist(b, o), dist(c, o)]
    D.sort()
    return D[2] - x * D[0]
o = [0.0, 0.0]
d = 1.0
R = 1e-15
T = int(1e5)
r = R ** (10 / T)
for _ in range(T):
    x = _ / T
    theta = (random.random() * 2.0 - 1.0) * math.pi
    while True:
        o2 = [o[0] + d * math.cos(theta), o[1] + d * math.sin(theta)]
        if f(o2) >= f(o):
            break
        o = o2
        d /= r
    d *= r
print(*o)
print(dist(a, o), dist(b, o), dist(c, o), file=open(2, "w"))
            
            
            
        