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

  • 相关阅读:
    VS扩展开发 二 从示例程序出发
    VS扩展开发 一 导航
    CLR笔记 二 函数调用
    使用C#调用C++类库
    C#编程常用工具总结
    CLR笔记 一 概述
    C#工程中 使用targets和props实例
    VS C++工程的静态库引用问题
    C#高级编程笔记(三)
    (转)如何让CPU的使用率一直在50%
  • 原文地址:https://www.cnblogs.com/kuangbin/p/2119801.html
Copyright © 2011-2022 走看看