http://acm.hdu.edu.cn/showproblem.php?pid=6550
这是一道好简单的数学题。。。要求保留6位小数。。。我pi写了8位精度还是炸了。。。我也不知道为啥。。。因为这了Wa了3发。。。
正多边形面积公式 n*r^2*sin(2pi/n) r是半径
这个题要求加一个点 根据三角形面积公式 要加在终点 而正好与一个内部的三角形构成一个对角线垂直的四边形

如图所示 因此面积公式为
(n-1)*r^2*sin(2pi/n)+r*r*sin(pi/n)
#include<algorithm>
#include<iostream>
#include<vector>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<string>
#include<queue>
#include<ctime>
#include<stack>
#include<map>
#include<set>
#include<cstring>
using namespace std;
typedef long long ll;
const double PI = 3.141592653589793238;
int main() {
int n;
while (cin >> n) {
//cout << (n - 1) * sin((2 * PI) / n)/2<< endl;
double ans = (n - 1)* sin(2 * PI/n)/2 + sin(PI / n);
printf("%.6f\n", ans);
}
return 0;
}







Comments | NOTHING