5.22 每日一题题解

C1.Simple Polygon Embedding

涉及知识点:

  • 简单计算几何

solution:

  • 题解转载于:https://blog.csdn.net/qq_43382350/article/details/106230278

  • \(求解正2*n边形的最小外接正方形(n为偶数)\)

  • \(由于n是偶数,所以在正2n边形中当中是会存在一个对称的情况\)

  • \(拿正2*4边形举个例子,你会发现我们EF和AB是平行的,同理GH//DC\)

  • \(如何求解呢,做个EF的中垂线,将角度设置为α\)

  • \(设圆心为o,其余点如图所示\)

  • \(设∠FOE=α,已知EF=1\)

  • \(即FJ/OJ=tan(α/2)\)

  • \(OJ = FJ / tan(α/2)\)

  • \(ans = 2 * OJ = 2 * FJ / tan(α/2)\)

  • \(已知J是中点 FJ = 1/2\)

  • \(ans = 1 / tan(α/2)\)

std:

#include <bits/stdc++.h>
using namespace std;
#define ll long long 
int main()
{
    int t;
    cin>>t;
    double PI = acos(-1);//圆周率的pai
    while(t--){
        int n;
        cin>>n;
        double x = 360/(double)(2*n)/2;
        double y = x*(PI/180);
        double ans = 1/tan(y);
        printf("%.10lf\n",ans);
    }
    return 0;
}

猜你喜欢

转载自www.cnblogs.com/QFNU-ACM/p/12936887.html
今日推荐