zoukankan      html  css  js  c++  java
  • ACM HDU 3668Volume

    Volume

    Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
    Total Submission(s): 531    Accepted Submission(s): 159


    Problem Description
    This time your job is to calculate the volume of a special object. The object consists of two orthogonal cylinders. The two cylinders intersect each other in the middle place. One example is shown in Fig. 1. The radiuses of the bottom disk of both cylinders are R, and the heights of both cylinders are H.

     

    Input
    We test the problem in many cases. Each case includes two integers, the first one is R and the second one is H. All the numbers given are positive integers and are less than 100.
     

    Output
    The output consists of the volumes. The results must be round to 4 decimal numbers. Remember that R may be less than half of H.
     

    Sample Input
    10 30 10 40
     

    Sample Output
    13516.2226 19799.4079
     

    Source
     

    Recommend
    lcy
     
    数学题,积分求体积
    #include<stdio.h>
    #include
    <iostream>
    #include
    <cmath>
    using namespace std;

    #define PI acos(-1.0)

    int main()
    {
    double r,h;
    double v;
    while(cin>>r>>h)
    {
    if(h>=2*r)
    v
    =2*PI*r*r*h-16*r*r*r/3;
    else
    v
    =2*PI*r*r*h-8*r*r*(r-sqrt(r*r-h*h/4))+8*(r*r*r-sqrt((r*r-h*h/4)*(r*r-h*h/4)*(r*r-h*h/4)))/3-8*h*h*sqrt(r*r-h*h/4)/4;
    printf(
    "%.4lf\n",v);
    }
    return 0;
    }

  • 相关阅读:
    float保留指定位数的小数
    springmvc中拦截器的使用
    springmvc文件上传
    spring注入
    mybatis动态代理
    2017《JAVA技术》预备作业02 计科1502 郎春雨
    2017《JAVA技术》预备作业01 计科1502 郎春雨
    字符串占位符的使用
    Pyenv虚拟环境的创建(虚拟机)
    Git的基本使用
  • 原文地址:https://www.cnblogs.com/kuangbin/p/2119801.html
Copyright © 2011-2022 走看看