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 }
    大佬见笑,,
  • 相关阅读:
    使用事件驱动代替定时任务
    MySql中的有条件插入 insert where
    Mac上“您没有权限来打开应用程序”(Big Sur)
    Java反编译反混淆神器
    Java实现开根号运算(不使用数组和String)
    使用vs code搭建Q#开发环境 (Mac)
    离散傅里叶变换DFT入门
    Java的nanoTime()方法
    Eslint提示const关键字被保留
    myBatis分页插件PageHelper的使用及源码详解
  • 原文地址:https://www.cnblogs.com/xwl3109377858/p/11286207.html
Copyright © 2011-2022 走看看