C1. Simple Polygon Embedding(计算几何)

  • 题面
  • 题意:给出一个偶数 n \small n ,求出正 2 n \small 2n 边形的对边之间的间距。
  • 解决思路:选择任意一条边,将这个边上的两个顶点与中心相连,并作中心点到边的垂线,运用三角函数的相关知识可以算出点到直线的距离,答案就是距离乘以 2 \small 2
  • AC代码
//优化
#pragma GCC optimize(2)
//C
#include<string.h>
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
//C++
//#include<unordered_map>
#include<algorithm>
#include<iostream>
#include<istream>
#include<iomanip>
#include<climits>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<set>
//宏定义
#define N 2010
#define DoIdo main
//#define scanf scanf_s
#define it set<ll>::iterator
//定义+命名空间
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 998244353;
const ll INF = 1e18;
const int maxn = 5e6 + 10;
using namespace std;
//全局变量
const double pi = acos(-1);
//函数区
ll max(ll a, ll b) { return a > b ? a : b; }
ll min(ll a, ll b) { return a < b ? a : b; }
//主函数
int DoIdo() {

	/*ios::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);*/

	int T;
	cin >> T;

	while (T--) {
		int n;
		cin >> n;

		double du = 360.000 / (double)(2 * n);
		du = du / 180 * pi;

		double ans = tan(du / 2.00);

		printf("%.10lf\n", 1 / ans);
	}
	return 0;
}
//分割线---------------------------------QWQ
/*


*/

猜你喜欢

转载自blog.csdn.net/qq_45739057/article/details/106209974