問題一覧 > 通常問題

No.105 arc's Hexagonal Bolt

レベル : / 実行時間制限 : 1ケース 5.000秒 / メモリ制限 : 512 MB / 小数誤差許容問題 絶対誤差または相対誤差が $10^{-6}$ 以下。ただし、ジャッジ側の都合で500桁未満にしてください
タグ : (AC するまで非表示) / 解いたユーザー数 134
作問者 : LayCurse
お気に入りにしたユーザー ProblemId : 198 / 自分の提出
問題文最終更新日: 2026-06-25 18:15:01
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 66 (順位表) の他の問題:

Problem Statement

The time for the annual hexagonal bolt inspection has come.
You must determine how much a tightened hexagonal bolt has loosened.
Since there are many to inspect, photographs were analyzed by image processing, and the coordinates $(X_k,Y_k),\ k=1,2,3,4,5,6$ of each vertex of the hexagon were obtained.
Initially, the vertices of the hexagonal bolt were at the coordinates $(1,0), (\frac{1}{2},\frac{\sqrt{3}}{2}), (-\frac{1}{2},\frac{\sqrt{3}}{2}), (-1,0), (-\frac{1}{2},-\frac{\sqrt{3}}{2}), (\frac{1}{2},-\frac{\sqrt{3}}{2})$.
Find by what angle it has loosened counterclockwise around the origin.
Since hexagonal bolts do not loosen so easily, you may assume that the loosened angle is at least $0$ degrees and less than $50$ degrees.
Also, the coordinates $X_k,Y_k$ resulting from the image analysis may contain errors, but you may assume that the absolute error is at most $10^{-12}$.
However, it is unknown in what order the $(X_k,Y_k)$ correspond to the $6$ vertices.
(Counterclockwise is the direction in which the $y$ coordinate increases when the point at coordinates $(1,0)$ is rotated slightly around the origin.)

(Hint: use inverse trigonometric functions. Be careful about errors.)

Input

The first line contains the number of test cases $T$.
It is followed by $T$ test cases in the format below.
Also, each test case is preceded by $1$ empty line.

$X_1$ $Y_1$
$X_2$ $Y_2$
$X_3$ $Y_3$
$X_4$ $Y_4$
$X_5$ $Y_5$
$X_6$ $Y_6$

$1 \leq T \leq 5000$
$(X_k,Y_k)$ satisfies the assumptions stated in the problem statement

Output

For each test case, output the angle by which the hexagonal bolt has loosened, in degrees, on $1$ line.
Your answer is considered correct if the absolute error or the relative error is at most $10^{-6}$.

Sample

Sample 1
Input
5

-0.7133129374161575 0.7008456701130583
0.7133129374169346 -0.7008456701123590
-0.9636066231566712 -0.2673242895938152
-0.2502936857416224 -0.9681699597070667
0.2502936857411194 0.9681699597067489
0.9636066231574117 0.2673242895944358

-0.8932333349173263 0.4495933822835123
-0.8359759578887596 -0.5487660684032287
0.0572573770290491 -0.9983594506862868
0.8932333349171817 -0.4495933822820707
0.8359759578898414 0.5487660684033163
-0.0572573770283012 0.9983594506864877

0.9160756762470419 0.4010054306221820
-0.1107569481506493 -0.9938475227307060
0.8053187280975752 -0.5928420921090568
-0.9160756762472804 -0.4010054306221356
0.1107569481505570 0.9938475227309645
-0.8053187280979552 0.5928420921086038

-0.1761571570426089 0.9843620553558652
0.1761571570408748 -0.9843620553541855
0.7644039679374461 0.6447376007350949
0.9405611249797644 -0.3396244546214024
-0.9405611249804702 0.3396244546202518
-0.7644039679385255 -0.6447376007346632

-0.4824203438123312 -0.8759398448960606
-0.9997963297728835 -0.0201816494043597
0.5173759859607933 -0.8557581954908735
0.9997963297734225 0.0201816494041266
0.4824203438109312 0.8759398448963396
-0.5173759859611117 0.8557581954911576
Output
15.5051083303987980
33.2824012264609337
23.6410478595644236
40.1460045250132680
1.1564018437638879
Sample 2 (added at 23:40 on December 16, 2014)
Input
5

-0.5000000000001114 0.8660254037853874
0.5000000000008891 -0.8660254037846875
-0.9999999999992328 0.0000000000005249
-0.5000000000002304 -0.8660254037850550
0.4999999999997271 0.8660254037847375
0.9999999999999735 0.0000000000000955

-0.5000000000000689 0.8660254037850319
-0.9999999999997544 0.0000000000007502
-0.4999999999992035 -0.8660254037838273
0.4999999999999247 -0.8660254037835899
1.0000000000008362 -0.0000000000006626
0.4999999999999509 0.8660254037840284

0.9999999999996566 0.0000000000007304
-0.5000000000006523 -0.8660254037851741
0.5000000000001875 -0.8660254037849764
-0.9999999999998951 -0.0000000000006841
0.5000000000005598 0.8660254037854329
-0.5000000000005670 0.8660254037845241

0.4999999999991134 0.8660254037851728
-0.5000000000008475 -0.8660254037834928
0.9999999999993000 0.0000000000009531
0.4999999999998960 -0.8660254037848518
-0.5000000000006016 0.8660254037837012
-1.0000000000003793 -0.0000000000005215

-0.5000000000004399 -0.8660254037845060
-1.0000000000000069 0.0000000000001151
0.4999999999998087 -0.8660254037837942
1.0000000000005458 -0.0000000000003484
0.4999999999990393 0.8660254037847854
-0.5000000000001267 0.8660254037840786
Output
0.0000000000000000
0.0000000000000000
0.0000000000000000
0.0000000000000000
0.0000000000000000

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。