给一个偶数 ,代表一个正 边形,求最小外接正方形的边长。
当 为偶数时,代表 一定可以被4整除,那么正方形一定可以和正 边形的4条边完美贴合。这就是最小的正方形。因为一旦进行旋转,正方形的面积就会增大,那么边长也会增大。
计算正方形边长:
正 边形内角用公式来算:
计算 长度:
正方形边长:
#include <bits/stdc++.h>
#define pb push_back
#define fir first
#define sec second
#define ms(a,b) memset(a,b,sizeof(a))
#define INF 0x3f3f3f3f
#define sp system("pause")
using namespace std;
typedef long long ll;
typedef double db;
const int N=1e4+5;
const int mod=10007;
const db pi=acos(-1.0);
int main()
{
int t;
double n;
cin>>t;
while(t--)
{
cin>>n;
printf("%lf\n",tan((n-1)*pi/n/2));
}
#ifndef ONLINE_JUDGE
sp;
#endif
}