PivotOJ

Bottle Flip

시간 제한: 1000ms메모리 제한: 1024MB출처: NWERC 2022BOJ 26175

문제

It marks the year 2022 where the bottle flip challenge finally reached the last people on earth; the NWERC Jury. As you may know, the objective of the challenge is to flip a bottle of water 360360^{\circ} through the air and hope that it lands standing upright. Figure B.1 demonstrates a successful bottle flip.

After many failed attempts, we noticed that this task gets significantly easier if the bottle is filled with just the right amount of water. The simple reason for this is that the amount of water affects the centre of mass of our bottle as it is about to land.1 A lower centre of mass makes it easier for the bottle to stay upright after it lands. Unfortunately, the optimal amount of water depends on the bottle, and we already wasted enough time on this challenge\dots

Figure B.1: Sketch of a bottle flip. The bottle is filled to roughly 33%33\% to ease the challenge.}

Given that our bottle is a perfect cylinder of height hh and radius rr, determine the optimal amount of water the bottle should contain so that our chances of landing a successful bottle flip are maximised. You can assume that both the water and the air contained in the bottle have uniform density, and that the weight of the bottle itself is negligible.


1For the sake of completeness, we define the centre of mass as the unique point at which the whole mass of the bottle could be concentrated without changing the bottle's reaction to gravity, regardless of the orientation of the bottle. Note that we implicitly assume that the water will stay at the bottom of the bottle. This defines exactly what you would intuitively think of as centre of mass.

입력

The input consists of:

  • One line with four integers hh, rr, dad_a, and dwd_w (1h,r,da,dw10001 \leq h, r, d_a, d_w \leq 1000, da<dwd_a < d_w), where hh and rr are the height and radius of the bottle, and dad_a and dwd_w are the densities of air and water, respectively.

출력

Output the height such that filling the bottle with water up to this height results in the lowest possible centre of mass while the bottle is standing upright. Your answer should have an absolute or relative error of at most 10610^{-6}.

예제

예제 1

입력
22 4 1 4
출력
7.3333333333

예제 2

입력
7 2 655 988
출력
3.1415941720
코드를 제출하려면 로그인하세요.