三棱锥之刻

原题链接

  • 题意:给出正四面体棱长 \(a\) 并且给出以正四面体为中心的半径 \(r\),求出以正四面体中心为球心,给出的半径 \(r\) 为半径求平面相交面积。
  • 题解:当我复习了一下正三棱锥和正四面体,并且顺便看了一下2019年全国一的数学第12道填空,然后这道题就切掉了。
  • 代码:
#include<bits/stdc++.h>

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ld pi = acos(-1.0);
void solve() {
    //cout << sqrt(3)/3 << endl;
    //cout << pi << endl;
    ld a, rp;
    cin >> a >> rp;
    ld r1, r2;
    ld b = a/sqrt(2);
    r1 = sqrt(a * a + b * b)/2;
    r2 = r1 - sqrt(b * b - a * a/3);
    ld realr = sqrt(rp*rp - r2 * r2);
    //cout << r1 << " " << r2 << endl;
    if (rp < r2) {
        cout << 0 << endl;return;
    }
    ld cmp_r1 = sqrt(3)*a/6;
    ld cmp_r2 = sqrt(3)*a/3;
    ld s1 = sqrt(3)*a*a/4;
    //cout << realr << endl;
    //cout << cmp_r2 << endl;
    if (realr > cmp_r2) {
        cout << setprecision(10)<<4*s1 << endl;
    } else if (realr < cmp_r1) {
        //while (1);
        cout << setprecision(10)<< 4 * pi * realr*realr << endl;
    } else {
        ld r = realr;
        ld h = cmp_r1;
        ld Cos_1 =  (4 * h * h-2 * r * r)/(2 * r*r);
        ld du = acos(Cos_1) * 3;
        ld s_san = h * sqrt(r * r - h * h);
        ld ans = s_san * 3 * 4;
        ans += pi * r * r * (2 * pi-du)/(2 * pi) * 4;
        cout << setprecision(10) << ans << endl;
    }
}
signed main() {
   ll t = 1;//cin >> t;
   while (t--) {
      solve();
   }
}
上一篇:获取windows系统盘符


下一篇:[NOI2009] 诗人小G [题解]