码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2019-08-02 12:47:41      阅读:70      评论:0      收藏:0      [点我收藏+]

标签:ice   row   bottom   https   ret   examples   input   ima   water   

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

标签:ice   row   bottom   https   ret   examples   input   ima   water   

原文地址:https://www.cnblogs.com/xwl3109377858/p/11286207.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!