Let's Construct! - ①
Time limit1sMemory limit512 MB
Given circle chord XY of length n with midpoint M, and PM with P defined by chords through M, find QY where Q is defined similarly and output it to two decimals.
- Level
Medium7 of 10
- Topics
- Geometry, Math, Implementation
- Solved
- No attempts yet
Problem
This afternoon, bored, Jaewon, the king of geometric construction, drew a circle on paper. Then he drew an arbitrary chord XY of the circle. He called the midpoint of chord XY M, and then drew chords AB and CD passing through M. Let P be the intersection of segment AD and chord XY, and let Q be the intersection of segment CB and chord XY. (Point A and point D lie on opposite sides of chord XY, and the six points X, Y, A, B, C, D are all distinct.)
Given the length n of chord XY and the length d of segment PM, write a program that finds the length of segment QY.
Input
The first line gives the positive integers n and d in that order, separated by a single space. n and d are positive integers at most 1,000, and d×2 is less than n.
Output
Print the length of segment QY rounded to the second decimal place. Floating-point error is not allowed; for example, if the answer is 8, you must print 8.0.
Hint
Jaewon constructs the figure as shown below. (The result of Jaewon's construction can change with the positions of A, B, C, D, X, Y and the values of n and d.)
