zoukankan      html  css  js  c++  java
  • Codeforces Round #576 (Div. 2) B

    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
    ",x);
    29     }
    30     
    31     return 0;
    32 }
    大佬见笑,,
  • 相关阅读:
    UVa 11181 (条件概率) Probability|Given
    UVa 1636 (概率) Headshot
    UVa 1262 (第k字典序) Password
    HDU 4746 (莫比乌斯反演) Mophues
    HDU 1695 (莫比乌斯反演) GCD
    POJ 3090 (欧拉函数) Visible Lattice Points
    CodeForces Round #283 Div.2
    UVa 10820 (打表、欧拉函数) Send a Table
    UVa 1635 (唯一分解定理) Irrelevant Elements
    Java基础10 接口的继承与抽象类
  • 原文地址:https://www.cnblogs.com/xwl3109377858/p/11286207.html
Copyright © 2011-2022 走看看