3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

AGC 036: A - Triangle

Posted at

数学的知識

3点 $(x_1, y_1), (x_2, y_2), (x_3, y_3)$ によって張られる三角形の面積を考えます。
一般に、ベクトル $\overrightarrow{\mathstrut a}, \overrightarrow{\mathstrut b}$ によって張られる三角形の面積は

S = \frac{1}{2}|\overrightarrow{\mathstrut a}||\overrightarrow{\mathstrut b}|\sin\theta

です。ただし、$\theta$ はベクトル $\overrightarrow{\mathstrut a}, \overrightarrow{\mathstrut b}$ がなす角です。三角関数に関する公式 $\sin^2\theta + \cos^2\theta = 1$ を用いると、

S = \frac{1}{2}|\overrightarrow{\mathstrut a}||\overrightarrow{\mathstrut b}|\sqrt{1 - \cos^2\theta}

と書けて、$\overrightarrow{\mathstrut a}\cdot\overrightarrow{\mathstrut b} = |\overrightarrow{\mathstrut a}||\overrightarrow{\mathstrut b}|\cos\theta$ ですから、

S = \frac{1}{2}\sqrt{|\overrightarrow{\mathstrut a}|^2|\overrightarrow{\mathstrut b}|^2 - (\overrightarrow{\mathstrut a}\cdot\overrightarrow{\mathstrut b})^2}

と変形することができます。
この問題の場合、$\overrightarrow{\mathstrut a} = (x_2-x_1, y_2-y_1), \overrightarrow{\mathstrut b} = (x_3-x_1, y_3-y_1)$ とおくと、

\begin{align}
S &= \frac{1}{2}\sqrt{[(x_2-x_1)^2+(y_2-y_1)^2][(x_3-x_1)^2+(y_3-y_1)^2] - [(x_2-x_1)(x_3-x_1)+(y_2-y_1)(y_3-y_1)]^2} \\
&= \frac{1}{2}\sqrt{[(y_2-y_1)(x_3-x_1) - (x_2-x_1)(y_3-y_1)]^2} = \frac{1}{2}\left|(y_2-y_1)(x_3-x_1) - (x_2-x_1)(y_3-y_1)\right|
\end{align}

と求めることができます。

解法

$(x_1,y_1) = (0,0)$ とおいて一般性を失いません。仮に $(x_1,y_1)$ を原点でない別の点においたとしても、$(x_2,y_2)\mapsto(x_2-x_1,y_2-y_1), (x_3,y_3)\mapsto(x_3-x_1,y_3-y_1)$ と変換することによって、$(x_1,y_1)$ を原点においた場合に帰着できるためです。
したがって、問いは次式を満たす $x_2,y_2,x_3,y_3$ を構築することに帰着します。

S = \left|y_2x_3 - x_2y_3\right|

すべて $10^9$ 以下という制約を満たすため、$(x_2,y_2) = (1,10^9)$ とおいてしまいます。すると、$S = \left|10^9x_3 - y_3\right|$ となるので、$S$ を $10^9$ で割った商と余りから $(x_3,y_3)$ を構成することができます。

感想

$x_3 = y_2 = \left\lceil \sqrt{S} \right\rceil$ とおいて $x_2y_3 = x_3y_2 - S$ を因数分解する(できなければ $x_3, y_2$ を増やしていく)という方法でACしたんですが、またしてもこれは嘘解法でした($S = 999999998499999999$ のとき、$x_2y_3 = 1500000001$ が素数なので分解できず $x_3 = y_2 = 10^9+1$ となってWAする)。

3
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?