zoukankan      html  css  js  c++  java
  • UVALIVE 5096 Volume

    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.

    epsfbox{p5096.eps}
    Fig.1 Two orthogonal cylinders

    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

    注意有2个情况分别是2*R大于小于H;
    2*R<H时就是直接的牟和方盖
    2*R>H图形就要自己画一个。自己画出来就是感觉 是一个长方体+牟合方盖 积分区间有变化
    两个圆弧面相交就会形成那个方盖图形样。之前这个圆弧面相交就简单的想象成一个圆柱的简单弧面那个样子。
    积分牟合方盖可以百度
    #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;
    }
    

      



  • 相关阅读:
    javascript语法之函数案例练习
    javascript语法之函数的定义
    javascript语法之with语句
    javascript语法之for-in语句
    javascript语法之循环语句小练习
    centos 7 配置samba mount
    Centos 7 systemd.service — Service unit configuration
    Linux 下使用 ffmpeg 大批量合并 ts 文件, mp4切割文件为m3u8
    Debian 系统修改网卡ens33名称为 eth0
    star_namelist
  • 原文地址:https://www.cnblogs.com/Commence/p/4339854.html
Copyright © 2011-2022 走看看