zoukankan      html  css  js  c++  java
  • CodeForces 630Q Pyramids(数学公式)

    IT City administration has no rest because of the fame of the Pyramids in Egypt. There is a project of construction of pyramid complex near the city in the place called Emerald Walley. The distinction of the complex is that its pyramids will be not only quadrangular as in Egypt but also triangular and pentagonal. Of course the amount of the city budget funds for the construction depends on the pyramids' volume. Your task is to calculate the volume of the pilot project consisting of three pyramids — one triangular, one quadrangular and one pentagonal.
    The first pyramid has equilateral triangle as its base, and all 6 edges of the pyramid have equal length. The second pyramid has a square as its base and all 8 edges of the pyramid have equal length. The third pyramid has a regular pentagon as its base and all 10 edges of the pyramid have equal length.

    Input

    The only line of the input contains three integers l3, l4, l5 (1 ≤ l3, l4, l5 ≤ 1000) — the edge lengths of triangular, quadrangular and pentagonal pyramids correspondingly.

    Output

    Output one number — the total volume of the pyramids. Absolute or relative error should not be greater than 10 - 9.

    Examples
    input
    2 5 3
    
    output
    38.546168065709


    题意:给你一个正三棱锥,正四棱锥和一个正五棱锥,每一个棱锥各自的所有边都相同,问这三个椎体加起来的体积。

    思路:这题就是要算正n棱锥的体积,注意如果用long double的话,可以在输入的时候用cin>>a>>b,输出的时候用printf("%.20f ",(double)ans);

    #include<iostream>
    #include<stdio.h>
    #include<stdlib.h>
    #include<string.h>
    #include<math.h>
    #include<vector>
    #include<map>
    #include<set>
    #include<queue>
    #include<stack>
    #include<string>
    #include<algorithm>
    using namespace std;
    typedef long long ll;
    #define inf 99999999
    #define pi acos(-1.0)
    long double cal(long double a,long double n)
    {
        long double R,alpha,h;
        alpha=pi/n;
        R=a/(sin(alpha)*2);
        h=sqrt(a*a-R*R);
        return h*n*a*a/(12*tan(alpha));
    }
    
    
    int main()
    {
        int i,j;
        long double l[6];
        while(cin>>l[3]>>l[4]>>l[5])
        {
            long double sum=0;
            for(i=3;i<=5;i++){
                sum+=cal(l[i],i);
            }
            printf("%.15f
    ",(double)sum);
        }
        return 0;
    }
    


  • 相关阅读:
    AJax封装避免页面重复代码
    word 2010 建立多级结构和目录
    (转)C# 选择正确的集合
    IIS7如何部署asp.net网站 (asp.net mvc 5 , asp.net 4.5 , asp.net 4.0 都可以 )
    (转)程序集清单定义与程序集引用不匹配- 分析及解决
    CentOS 6.5 安装 MySQL5.6 并用Navicat for MySQL 连接
    用EF访问Centos下的MySQL
    SQLServer中的页如何影响数据库性能 (转)
    .NET Framework各版本比较
    EntityFramework简介
  • 原文地址:https://www.cnblogs.com/herumw/p/9464550.html
Copyright © 2011-2022 走看看