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

      



  • 相关阅读:
    Design Thinking 设计思维
    SELECT小技巧
    网站架构
    代码生成器重构
    如何监控你的鼠标
    Asp.net超轻异步框架
    跨线程修改UI控件
    NPOI组件
    浅析Linux计算机工作机制
    VS2010单元测试
  • 原文地址:https://www.cnblogs.com/Commence/p/4339854.html
Copyright © 2011-2022 走看看