写过几次吧
第一次想到方法,但是没想到正多面体只有5种
第二次的时候手头没有计算公式
因为是体积扩展,所以必然是面积*h,还有棱上的圆柱体,以及定点上的圆弧,圆柱体的体积是和二面角的补角有关。定点的话所有的定点之和可以凑成一个圆
#include <cstdio>
#include <cstring>
#include <algorithm>
#include<iostream>
#include<queue>
#include<map>
#include<cmath>
using namespace std;
const int maxn = 57;
#define MAXN 100005
#define ll long long
#define PI acos(-1.0)
int main()
{
int T;
cin >> T;
map<int, int>ma;
ma[4] = 6;
ma[8] = 12;
ma[12] = 30;
ma[20] = 30;
ma[6] = 12;
while (T--)
{
int n, l, h;
cin >> n >> l >> h;
double ans = 0.0, s; double angle; int leng;
if (n == 4 || n == 8 || n == 12 || n == 20||n==6)
{
if (n == 4)
s = sqrt(3)*l*l, angle =PI-acos(1.0 / 3.0);
else if (n == 8)
s = 2.0*sqrt(3.0)*l*l, angle = PI-acos(-1.0 / 3.0);
else if (n == 12)
s = 12.0*sqrt(25.0 + 10.0*sqrt(5.0)) / 4.0*l*l,angle=PI-acos(-sqrt(5)/5.0);
else if (n == 20)
s = 5.0*sqrt(3)*l*l, angle = PI-acos(-sqrt(5) / 3.0);
else if (n == 6)
s = 6.0*l*l,angle=PI/2.0;
leng = ma[n];
ans += (s*h);
ans += (PI*h*h*l /(2.0*PI)*angle*leng);
ans += (4.0 / 3.0*PI*h*h*h);
}
else { cout << 0 << endl; continue; }
printf("%.10f\n", ans);
}
return 0;
}