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

  • 相关阅读:
    Vue v-if v-for v-bind v-on
    Vue v-bind的使用
    Vue绑定事件
    vue绑定内联样式
    Vue简单使用
    js实现UTC时间转为北京时间,时间戳转为时间
    setTimeOut函数传参数
    直播聊天室,点亮效果,jquery实现
    聊天室自动滚动效果实现
    融云rongCloud聊天室的使用
  • 原文地址:https://www.cnblogs.com/kuangbin/p/2119801.html
Copyright © 2011-2022 走看看