CodeForces - 630Q Pyramids (数学几何&公式)

CodeForces - 630Q
Time Limit: 500MS Memory Limit: 65536KB 64bit IO Format: %I64d & %I64u

 Status

Description

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 than10 - 9.

Sample Input

Input
2 5 3
Output
38.546168065709

Source

//题意:
给你正三棱锥,正四棱锥,正五棱锥的边长l3,l4,l5,问它们的体积和为多少。
//正三棱锥,正四棱锥的体积都很好算,但正五棱锥的体积算了一晚上还是错的,看了大神的博客才稍微懂点。。。
计算几何,重点在求高
正四面体 高 这里写图片描述 底面积 这里写图片描述 体积 这里写图片描述
正五面体 高 这里写图片描述 底面积 这里写图片描述 体积 这里写图片描述
正六面体 高 这里写图片描述 底面积 这里写图片描述 其中 这里写图片描述
体积 这里写图片描述
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#define INF 0x3f3f3f3f
#define ll long long
#define N 10010
#define M 1000000007
#define PI acos(-1.0)
using namespace std;
int main()
{
	double l1,l2,l3;
	while(scanf("%lf%lf%lf",&l1,&l2,&l3)!=EOF)
	{
		double h1=sqrt(6)*l1/3;
		double s1=sqrt(3)*l1*l1/4;
		double v1=(1.0/3)*h1*s1;
		
		double h2=sqrt(2)*l2/2;
		double s2=l2*l2;
		double v2=(1.0/3)*h2*s2;
		
		double k=0.5/(tan(18.0/180*PI)*(1+cos(36.0/180.0*PI)));
		double h3=sqrt(1-k*k)*l3;
		double x3=k*l3;
		double v3=5.0*l3*x3*cos(36.0/180*PI)*h3/6.0;
		
		double v=v1+v2+v3;
		printf("%.10lf\n",v);
	}
	return 0;
}

//下面的更简洁,用数学公式。
#include<stdio.h>  
#include<string.h>  
#include<math.h>  
#include<algorithm>  
#include<iostream>  
#include<queue>  
#define INF 0x3f3f3f3f  
#define IN __int64  
#define ull unsigned long long  
#define ll long long  
#define N 1010  
#define M 1000000007  
#define PI acos(-1.0)
using namespace std;
double V(double a,double n)
{
	double jiao=PI/n;
	double r=a/(2*sin(jiao));
	double h=sqrt(a*a-r*r);
	double v=h*n*a*a/(12*tan(jiao));
	return v;
}
int main()
{
	double l[6];
	while(scanf("%lf%lf%lf",&l[3],&l[4],&l[5])!=EOF)
	{
		double v=0;
		for(int i=3;i<=5;i++)
		{
			v+=V(l[i],i);
		}
		printf("%.10lf\n",v);
	}
	return 0;
}


  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值