#abc279d. D - Freefall

D - Freefall

Score : 400400 points

问题描述

超人高桥即将从一栋楼的屋顶跳下,以帮助地面上处于困境的人。高桥所在星球有一个恒定值 gg,代表重力强度,他开始下落到达地面所需的时间为 Ag\frac{A}{\sqrt{g}}

现在时间为 00,且 g=1g = 1。高桥将根据需要(可能为零)执行以下操作任意多次:

  • 使用超能力将 gg 的值增加 11。这个过程需要花费时间 BB

然后,他会从楼顶跳下。开始下落后,他无法再改变 gg 的值。另外,我们只考虑进行该操作以及下落所花费的时间。

请找出高桥最早能在何时到达地面。

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

A superman, Takahashi, is about to jump off the roof of a building to help a person in trouble on the ground. Takahashi's planet has a constant value gg that represents the strength of gravity, and the time it takes for him to reach the ground after starting to fall is Ag\frac{A}{\sqrt{g}}.

It is now time 00, and g=1g = 1. Takahashi will perform the following operation as many times as he wants (possibly zero).

  • Use a superpower to increase the value of gg by 11. This takes a time of BB.

Then, he will jump off the building. After starting to fall, he cannot change the value of gg. Additionally, we only consider the time it takes to perform the operation and fall.

Find the earliest time Takahashi can reach the ground.

Constraints

  • 1A10181 \leq A \leq 10^{18}
  • 1B10181 \leq B \leq 10^{18}
  • All values in the input are integers.

Input

The input is given from Standard Input in the following format:

AA BB

Output

Print the earliest time Takahashi can reach the ground. Your output will be accepted when its absolute or relative error from the true value is at most 10610^{-6}.

Sample Input 1

10 1

Sample Output 1

7.7735026919
  • If he performs the operation zero times, he will reach the ground at time 1×0+101=101\times 0+\frac{10}{\sqrt{1}} = 10.
  • If he performs the operation once, he will reach the ground at time 1×1+1028.071\times 1+\frac{10}{\sqrt{2}} \fallingdotseq 8.07.
  • If he performs the operation twice, he will reach the ground at time 1×2+1037.771\times 2+\frac{10}{\sqrt{3}} \fallingdotseq 7.77.
  • If he performs the operation three times, he will reach the ground at time 1×3+104=81\times 3+\frac{10}{\sqrt{4}} = 8.

Performing the operation four or more times will only delay the time to reach the ground. Therefore, it is optimal to perform the operation twice before jumping off, and the answer is 2+1032+\frac{10}{\sqrt{3}}.

Sample Input 2

5 10

Sample Output 2

5.0000000000

It is optimal not to perform the operation at all.

Sample Input 3

1000000000000000000 100

Sample Output 3

8772053214538.5976562500

update @ 2024/3/10 11:44:32