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

  • 相关阅读:
    Java学习——HashMap
    git 常用命令
    java 正则表达式
    java 读写文件
    python Shapely 使用指南
    java 删除目录、 文件
    Java maven安装GDAL
    postgresql运维
    (转)媒体格式分析之flv -- 基于FFMPEG
    (转)rtmp协议简单解析以及用其发送h264的flv文件
  • 原文地址:https://www.cnblogs.com/kuangbin/p/2119801.html
Copyright © 2011-2022 走看看