欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

C1. Simple Polygon Embedding——(平面几何)

程序员文章站 2022-06-03 19:34:34
...

总结

几何算法,很少遇到,一遇到就死的很惨,没法看
C1. Simple Polygon Embedding——(平面几何)
== n为偶数 ==

每次增加2*2,四条边一定在正方形上:
ans = 1.0 / tan(PI / (2 * n))
== n为奇数==
我不会,cos(PI / (4 * n)) / sin(PI / (2 * n))

题目链接

//#pragma GCC optimize(2)
#include<bits/stdc++.h>
//typedef long long ll;
#define ull       unsigned long long
#define int       long long
#define F           first
#define S           second
#define endl        "\n"//<<flush
#define eps         1e-6
#define base        131
#define lowbit(x)   (x&(-x))
#define PI          acos(-1.0)
#define inf         0x3f3f3f3f
#define MAXN        0x7fffffff
#define INF         0x3f3f3f3f3f3f3f3f
#define ferma(a,b)  pow(a,b-2)
#define pb          push_back
#define decimal(x)  cout << fixed << setprecision(x);
#define all(x)      x.begin(),x.end()
#define memset(a,b) memset(a,b,sizeof(a));
#define IOS         ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;
void file()
{
#ifdef ONLINE_JUDGE
#else
    freopen("D:/LSNU/codeforces/duipai/data.txt","r",stdin);
    //  freopen("D:/LSNU/codeforces/duipai/WA.txt","w",stdout);
#endif
}
signed main()
{
    IOS;
    file();
    int t;
    cin>>t;
    while(t--)
    {
        int n;
        cin>>n;
        n*=2;
        double degree=(n-2)*180*1.0/n/2*PI/180;
        decimal(6);
        cout<<tan(degree)<< endl;
    }
    return 0;
}
相关标签: 几何