102793: [AtCoder]ABC279 D - Freefall
Description
Score : $400$ points
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 $g$ that represents the strength of gravity, and the time it takes for him to reach the ground after starting to fall is $\frac{A}{\sqrt{g}}$.
It is now time $0$, and $g = 1$. Takahashi will perform the following operation as many times as he wants (possibly zero).
- Use a superpower to increase the value of $g$ by $1$. This takes a time of $B$.
Then, he will jump off the building. After starting to fall, he cannot change the value of $g$. Additionally, we only consider the time it takes to perform the operation and fall.
Find the earliest time Takahashi can reach the ground.
Constraints
- $1 \leq A \leq 10^{18}$
- $1 \leq B \leq 10^{18}$
- All values in the input are integers.
Input
The input is given from Standard Input in the following format:
$A$ $B$
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 $10^{-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\times 0+\frac{10}{\sqrt{1}} = 10$.
- If he performs the operation once, he will reach the ground at time $1\times 1+\frac{10}{\sqrt{2}} \fallingdotseq 8.07$.
- If he performs the operation twice, he will reach the ground at time $1\times 2+\frac{10}{\sqrt{3}} \fallingdotseq 7.77$.
- If he performs the operation three times, he will reach the ground at time $1\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+\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
Input
题意翻译
给定两个数 $a$,$b$($1 \le a, b \le 10^{18}$),求出 $\min\limits_{g = 1}^\infty\{b \times (g - 1) + \frac{a}{\sqrt{g}}\}$。精度误差不超过 $10^{-6}$。 translated by @[liangbowen](https://www.luogu.com.cn/user/367488)。Output
分数:400分
问题描述
超人高桥即将从一栋楼的屋顶跳下来帮助地面上的一个陷入困境的人。 高桥所在的星球有一个表示重力强度的恒定值$g$,从开始下落到达地面所需的时间为$\frac{A}{\sqrt{g}}$。
现在是时间$0$,$g = 1$。 高桥可以按需执行以下操作任意次(包括零次):
- 使用超能力将$g$的值增加$1$。这需要$B$的时间。
然后,他会跳下大楼。开始下落之后,他不能改变$g$的值。此外,我们只考虑执行操作和下落所需的时间。
找出高桥最早可以到达地面的时间。
约束条件
- $1 \leq A \leq 10^{18}$
- $1 \leq B \leq 10^{18}$
- 输入中的所有值都是整数。
输入
输入将从标准输入以以下格式给出:
$A$ $B$
输出
打印高桥最早可以到达地面的时间。 当您的输出与真实值的绝对误差或相对误差不超过$10^{-6}$时,您的输出将被接受。
样例输入1
10 1
样例输出1
7.7735026919
- 如果他执行零次操作,他将在时间$1\times 0+\frac{10}{\sqrt{1}} = 10$到达地面。
- 如果他执行一次操作,他将在时间$1\times 1+\frac{10}{\sqrt{2}} \fallingdotseq 8.07$到达地面。
- 如果他执行两次操作,他将在时间$1\times 2+\frac{10}{\sqrt{3}} \fallingdotseq 7.77$到达地面。
- 如果他执行三次操作,他将在时间$1\times 3+\frac{10}{\sqrt{4}} = 8$到达地面。
执行四次或更多次操作只会延迟到达地面的时间。 因此,最优的做法是在跳下之前执行两次操作,答案是$2+\frac{10}{\sqrt{3}}$。
样例输入2
5 10
样例输出2
5.0000000000
最优做法是不执行任何操作。
样例输入3
1000000000000000000 100
样例输出3
8772053214538.5976562500