No.735 Tangent Line
タグ : / 解いたユーザー数 341
作問者 :
butsurizuki
/ テスター :
Note
2026/10/14 The allowed error has been changed to 0.001. This is because 99_system_test1.txt is quite a severe case.
Reading 524288.000001 into a double already exceeds a precision of $10^{-6}$.
The code that solves this most accurately: #1193071
Problem Statement
There are a circle $O$ of radius $r$ and a point $A$ outside the circle at distance $d$ from $O$.
Draw a tangent from point $A$ to circle $O$, and let $L$ be the point of tangency. Find the length of segment $AL$.
(Two tangents can be drawn from point $A$ to circle $O$, but it can be shown that both have the same length.)
Input
$r$ $d$
・Constraints
$0 < r < d < 10^6$
$r,d$ are given to the 6th decimal place
Output
Output the answer on one line, followed by a newline.
An absolute or relative error of at most $10^{-3}$ is allowed.
Sample
Sample 1
Input
3.000000 5.000000
Output
4.000000000000
Sample 2
Input
123.456789 123.456790
Output
0.015713483953
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。