KONSTRAKSCHION - Weird Construction


Vieri Corp, a technology company, has requested Bima, a constructor, to build an isosceles triangle on their brand new field. On each vertex of the triangle, they requested a pole A, B and C where AB = BC. It is guaranteed that B is the shortest pole. They also requested a rope of length x and y to connect the tip of the poles AB and BC respectively. Given the height of pole A, C and the length of rope x and y help Bima calculate the the height of pole B. You should minimize B. I've decreased the constraints so don't worry about precision error :) It is guaranteed that there will be an answer. The ropes cannot be loose. The pole's diameter is negligible.

Refer to the image below for better understanding.

poles description

Input

A C x y

Output

The height of pole B correct to 3 decimal places.

Examples

Input 1:
10 20 10 18.973665961

Output 1:
2.000000
Input 2:
10 7 8.5 6.0207972894

Output 2:
2.500

Constraints

  • 1 ≤ A ≤ 500000
  • 1 ≤ C ≤ 500000
  • 1 ≤ x ≤ 500000
  • 1 ≤ y ≤ 500000

hide comments
Oleg: 2023-01-06 02:06:38

I still see tests where this triggers assertion error:
assert (y < x + A-C + 1e-2)

for example for test "5 4 1 3" that geometrically not possible what should be an answer?

Last edit: 2023-01-06 02:06:50
Simes: 2022-11-27 11:57:35

@Juan, you should add a test case like 10 10 5 5. My first AC code gave 0, which is obviously wrong.

[Rampage] Blue.Mary: 2022-03-13 01:36:49

I've resubmitted my AC solution and it gets WA.

Edit: Now the test data has been fixed.

Last edit: 2022-06-22 13:48:58
Oleg: 2022-03-12 20:35:52

WARNING: After tests updated in 2020-08, there was no accepted solutions. Suspect mistakes in updated test.
nadstratosfer@ Can you resubmit accepted solution to verify it?

David: 2022-02-03 18:35:13

Does "correct to 3 decimal places" mean truncate to 3 decimal places or round to 4 decimal places? Description and output is unclear, as there are two different number of decimal places in output.

Oleg: 2020-08-13 02:17:11

Is it correct drawing of first case after rotating poles? https://imgur.com/TdsWVVR

Reply from author: yes, it's correct.

In this case we can rotate poles - see https://imgur.com/gMDYYtk - if solution exists we should get triangle with sides x, y and |A-C| that only exists if y <= x + |A-C|, x <= y + |A-C|, |A-C| <= x + y.

Please point where this is wrong and how solution is possible with y > x + |A - C|. Can you share one test case with y > x + |A - C| and solution that exists?

There were no accepted solutions after tests were updated. Please double check tests.

Last edit: 2020-10-11 06:24:39
nadstratosfer: 2020-05-21 15:59:44

Please get rid of HTML formatting that messes up the dark mode view: http://imgbox.com/bix7PScc .

Also clarify the statement, right now A/B/C as well as AB/BC are used interchangeably for distinct concepts. A picture would be useful here.

Reply from author: hi, thank you for viewing my question. I will edit the HTML formatting and add a picture shortly. Thank you for your input!

update: I've updated the HTML format and added an image. Have fun with the problem!

[NG]: Thanks for the corrections. Fun was had! Some remarks for possible improvements in future problems:
- Use small number of testfiles, but multiple cases each. That takes the load off servers and speeds up the judging, but also causes less runtime distortion for compilers with startup lag.
- Use https://www.spoj.com/uploads/ for images so they'll be here as long as SPOJ exists (unlike 3rd party hosters).

another reply from author: I was glad you were having fun! I will note your feedback for future problems. Thank you very much.

Last edit: 2020-05-22 02:43:33

Added by:Juan
Date:2020-05-21
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64
Resource:own problem