No.2632 Center of Three Points in Lp Norm
Problem Statement
$$ \gdef\norm#1{\|#1\|_p} $$
There are $3$ points $\bm a, \bm b, \bm c \in \R^2$ on the plane. It is guaranteed that the $3$ points are not collinear.
You are given a real number $p\ (p > 1)$. It can be shown that there exists a unique point $\bm o \in \R^2$ on the plane satisfying $\norm{\bm a - \bm o} = \norm{\bm b - \bm o} = \norm{\bm c - \bm o}$. Find this point.
What is $\norm{\cdot}$?
For $\bm v = (v_x, v_y) \in \R^2$, the function $\norm{\cdot}$ defined by $\norm{\bm v} := \sqrt[p]{|v_x|^p + |v_y|^p}$ is called the $L_p$ norm on $\R^2$.
Input
Let $\bm a = (a_x, a_y), \bm b = (b_x, b_y), \bm c = (c_x, c_y)$. The input is given in the following format.
$p$ $a_x$ $a_y$ $b_x$ $b_y$ $c_x$ $c_y$
- $1 < p \le 10$
- $p$ can be represented with up to $2$ decimal places.
- $p$ is given to $2$ decimal places.
- $a_x, a_y, b_x, b_y, c_x, c_y$ are integers.
- $|a_x|, |a_y|, |b_x|, |b_y|, |c_x|, |c_y| \le 10^6$
- $\bm a, \bm b, \bm c$ are not collinear. That is, $(b_x - a_x)(c_y - a_y) \ne (b_y - a_y)(c_x - a_x)$.
Output
Let the answer be $\bm o = (o_x, o_y)$. Output it in the following format.
$o_x$ $o_y$
- It is guaranteed that only inputs such that $|o_x|, |o_y| \le 10^6$ are given.
- Your answer is considered correct if, for both of $o_x, o_y$, the error from the judge's answer is at most $10^{-6} \times \max\lbrace|a_x|, |a_y|, |b_x|, |b_y|, |c_x|, |c_y|, |o_x|, |o_y|\rbrace$.
- It is guaranteed that the error of the judge's answer from the true value is at most $10^{-9} \times \max\lbrace|a_x|, |a_y|, |b_x|, |b_y|, |c_x|, |c_y|, |o_x|, |o_y|\rbrace$.
Sample
Sample 1
Input
2.00 0 0 1 2 2 1
Output
0.8333333333333333 0.8333333333333333
When $p = 2$, this is the Euclidean norm, so the problem amounts to finding the circumcenter of triangle $abc$. The circumcenter of the triangle formed by the $3$ points $(0, 0), (1, 2), (2, 1)$ is $(\frac56, \frac56)$.
Sample 2
Input
1.01 0 0 10 11 10 12
Output
-67404.742292524454 11.500000000000
Sample 3
Input
10.00 1000000 1000000 1000000 -1000000 -1000000 1000000
Output
0.000000000000 0.000000000000
Sample 4
Input
1.30 -470435 45348 -761809 816083 -981690 690686
Output
-773918.441905843330 323415.921812938722
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
tatyam
noya2