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;
    }
    

      

  • 相关阅读:
    9.12 其他样式;JS
    9.11 样式表
    9.9 样式表
    PHP延迟几秒后执行,PHP延迟执行,PHP停顿几毫秒后执行 usleep() 和 sleep()
    PHP 去除url参数中出现+、空格、=、%、&、#等字符的解决办法, PHP去除影响url路径的字符
    java第一堂课-常用的电脑快捷键操作和重要的dos命令
    常用第三方接口,支付宝支付,微信支付,软著,IOS开发者账号
    苹果开发者账号申请流程完整版 https://www.jianshu.com/p/655380201685
    thinkphp 去重查询
    将数据导【入】【excel表】格式 前端页面
  • 原文地址:https://www.cnblogs.com/Commence/p/4339860.html
Copyright © 2011-2022 走看看