zoukankan      html  css  js  c++  java
  • UVALIVE 4330 Timer

    Description

    Download as PDF
     

    Recently, some archaeologists discovered an ancient relic on a small island in the Pacific Ocean. In the relic, they found an interesting cone shaped container with transparent bottom. The container lay on the horizontal ground with its central axis parallel to the ground. Just beside the container, they found a manual telling them something about the container. The container was a timer for a special ceremony. Ancient people filled it all with water before the ceremony, and when the ceremony began, they pulled out the plug in the small hole on the tip of the cone to let the water out. There was a horizontal line called ``sacred line" carved on the bottom of the cone, and when the water level hit that line, they pushed the plug back and ended the ceremony. But the archaeologists could not found the sacred line on that cone. In order to sell the timer at a good prize, the archaeologists wanted to recover that very important line. By the manual they figured out how much water flew out when the ceremony ended, but they don't know what to do next, so they come to you for help.

    They measures the height of the cone, and the diameter of the bottom, you should tell them the sacred line's height above the ground.

    epsfbox{p4330.eps}<tex2html_verbatim_mark>

    Input

    The first line of the input contains an integer T<tex2html_verbatim_mark>(1$ le$T$ le$20)<tex2html_verbatim_mark> , indicating the number of test cases. Each line after that is a test case. It contains three real numbers, H<tex2html_verbatim_mark> , D<tex2html_verbatim_mark>(1$ le$HD$ le$1000)<tex2html_verbatim_mark> and V<tex2html_verbatim_mark> , indicating the height and bottom diameter of the timer, and the volume of water that flew out during the ceremony. That volume is guaranteed to be less than half volume of the container.

    Output

    For each test case, output one line containing the height of the sacred line above the ground. You should round off the answers to the 5th decimal place. (For example, rounding off 4.000005 equals to 4.00001 and rounding off 4.000004 equals to 4.00000)


    Hint: Here are some formulas you may need. Please notice that in these formulas, Log means log e<tex2html_verbatim_mark> or ln.

    $ int$$ sqrt{{x^{2}-a^{2}}}$dx = $ {frac{{1}}{{2}}}$x$ sqrt{{x^{2}-a^{2}}}$ - $ {frac{{1}}{{2}}}$a2Log[x + $ sqrt{{x^{2}-a^{2}}}$] + C<tex2html_verbatim_mark>

    $ int$$ sqrt{{x^{2}+a^{2}}}$dx = $ {frac{{1}}{{2}}}$x$ sqrt{{x^{2}+a^{2}}}$ + $ {frac{{1}}{{2}}}$a2Log[x + $ sqrt{{x^{2}+a^{2}}}$] + C<tex2html_verbatim_mark>

    $ int$$ sqrt{{a^{2}-x^{2}}}$dx = $ {frac{{1}}{{2}}}$(x$ sqrt{{a^{2}-x^{2}}}$ + a2ArcTan[$ {frac{{x}}{{sqrt{a^{2}-x^{2}}}}}$]) + C<tex2html_verbatim_mark>

    $ int$Log[a + $ sqrt{{a^{2}-x^{2}}}$]dx = a ArcTan[$ {frac{{x}}{{sqrt{a^{2}-x^{2}}}}}$] + x(- 1 + Log[a + $ sqrt{{a^{2}-x^{2}}}$]) + C<tex2html_verbatim_mark>

    $ int$xLog[a + $ sqrt{{a^{2}-x^{2}}}$]dx = $ {frac{{1}}{{4}}}$(a2 - x2 -2a$ sqrt{{a^{2}-x^{2}}}$ +2x2Log[a + $ sqrt{{a^{2}-x^{2}}}$]) + C<tex2html_verbatim_mark>

    $ int$x2Log[a + $ sqrt{{a^{2}-x^{2}}}$]dx = $ {frac{{1}}{{18}}}$(- 2x3 -3ax$ sqrt{{a^{2}-x^{2}}}$ +3a3ArcTan[$ {frac{{a}}{{sqrt{a^{2} - x^{2}}}}}$] + 6x3Log[a + $ sqrt{{a^{2}-x^{2}}}$]) + C<tex2html_verbatim_mark>

    Sample Input

    2 
    5.0 10.0 0.0 
    5.0 10.0 65.4498
    

    Sample Output

    10.00000 
    5.00000

    二分解决 就是积分这个体积我自己没挤出来看了别人的代码。直接粘过来了记录一下 二分还是比较容易理解的
    #include <map>
    #include <set>
    #include <list>
    #include <cmath>
    #include <ctime>
    #include <deque>
    #include <stack>
    #include <queue>
    #include <cctype>
    #include <cstdio>
    #include <string>
    #include <vector>
    #include <climits>
    #include <cstdlib>
    #include <cstring>
    #include <iostream>
    #include <algorithm>
    #define LL long long
    #define PI 3.1415926535897932626
    using namespace std;
    int gcd(int a, int b) {return a % b == 0 ? b : gcd(b, a % b);}
    int main()
    {
            double r,h,ans,v;
            while (cin >> r >> h)
            {
                    v = 2 * r * r * PI * h;
                    if (r * 2 > h)
                    {
                            double temp = sqrt(r * r - h * h / 4);
                            ans = temp * h * h / 4 + r * r * r * 2 / 3 - r * r * temp + temp * temp * temp / 3;
                    }
                    else
                    ans = r * r * r * 2 / 3;
                    printf("%.4lf
    ",v - ans * 8);
            }
            return 0;
    }
    

      

  • 相关阅读:
    [JavaEE] Hibernate ORM
    [PHP] htaccess 探秘
    [JavaEE] SSH框架搭建所需要的包
    博客园使用技巧
    vs快捷键
    算法:递归、循环、迭代、哈希表、查找、内排序、外排序
    【译】.NET中六个重要的概念:栈、堆、值类型、引用类型、装箱和拆箱 --转载
    .NET框架与开发语言:相关框架、共用部分、开发语言、一些疑问
    c#原理:c#代码是怎么运行的、实例化时发生了什么、静态对象(类、方法、变量、属性)的原理
    EA:UML建模-流程图、时序图、部署图
  • 原文地址:https://www.cnblogs.com/Commence/p/4339860.html
Copyright © 2011-2022 走看看