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

      



  • 相关阅读:
    20165105 学习基础和C语言基础调查
    2017-2018网络攻防第四周作业
    2017-2018-2 20165233 实验三 敏捷开发与XP实践
    20165233 2017-2018-2 《Java程序设计》第九周学习总结
    Linux学习笔记(一)
    第三周学习总结
    数据结构C++,线性表学习
    uname()系统调用学习
    cd
    go连接数据库并执行文件中的sql语句
  • 原文地址:https://www.cnblogs.com/Commence/p/4339854.html
Copyright © 2011-2022 走看看