Codeforces Round #576 (Div. 2) B - Water Lily

Posted xwl3109377858

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Codeforces Round #576 (Div. 2) B - Water Lily相关的知识,希望对你有一定的参考价值。

Codeforces Round #576 (Div. 2)

 

B - Water Lily

While sailing on a boat, Inessa noticed a beautiful water lily flower above the lake‘s surface. She came closer and it turned out that the lily was exactly H centimeters above the water surface. Inessa grabbed the flower and sailed the distance of L centimeters. Exactly at this point the flower touched the water surface.

技术图片

 

 

Suppose that the lily grows at some point A on the lake bottom, and its stem is always a straight segment with one endpoint at point A. Also suppose that initially the flower was exactly above the point A, i.e. its stem was vertical. Can you determine the depth of the lake at point A?

Input

The only line contains two integers H and L (1≤H<L≤10^6).

Output

Print a single number — the depth of the lake at point A. The absolute or relative error should not exceed 10^−6.

Formally, let your answer be A, and the jury‘s answer be B. Your answer is accepted if and only if |A−B|max(1,|B|)≤10^−6.

Examples

input

1 2

output

1.5000000000000

input

3 5

output

2.6666666666667

 

思路:几何数学题,看图我们可以列出方程 技术图片 ,

化简之后得 技术图片 ,由此得解

 

 1 #include<iostream>
 2 #include<cstdio>
 3 #include<cmath>
 4 #include<cstring>
 5 #include<map>
 6 #include<set>
 7 #include<vector>
 8 #include<algorithm>
 9 #include<queue>
10 #include<unordered_map>
11 #include<list>
12 using namespace std;
13 #define ll long long 
14 const int mod=1e9+7;
15 const int inf=1e9+7;
16  
17 const int maxn=1e5+5;
18  
19 int main()
20 
21     //ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
22     
23     double H,L;
24     
25     while(cin>>H>>L)
26     
27         double x=(L*L-H*H)/(2*H);
28         printf("%.10f\\n",x);
29     
30     
31     return 0;
32 

 

以上是关于Codeforces Round #576 (Div. 2) B - Water Lily的主要内容,如果未能解决你的问题,请参考以下文章

Codeforces Round #576 (Div. 2) D. Welfare State

codeforces 576c// Points on Plane// Codeforces Round #319(Div. 1)

Codeforces Round #436 E. Fire(背包dp+输出路径)

[ACM]Codeforces Round #534 (Div. 2)

Codeforces Round #726 (Div. 2) B. Bad Boy(贪心)

Codeforces 576C. Points on Plane(构造)