logo AlgoBeat OnlineJudge
登录 注册

#217055. [NWERC 2022] Bottle Flip

内存限制:512 MiB 时间限制:1000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

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 through the air and hope that it lands standing upright. The figure below demonstrates a successful bottle flip.

:::align{center} :::

Figure: Three bottles with different amounts of water.

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. For 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.

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...

:::align{center} :::

Figure: Sketch of a bottle flip. The bottle is filled to roughly to ease the challenge.

Given that our bottle is a perfect cylinder of height and radius , 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.

输入格式

The input consists of one line with four integers , , , and (, ), where and are the height and radius of the bottle, and and 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 .

样例

样例输入 1

22 4 1 4

样例输出 1

7.3333333333

样例输入 2

7 2 655 988

样例输出 2

3.1415941720