G.Circle(hdu6550)

 

 解题思路:先用正弦定理  1/2*a*b*sinC 求一部分内接多边形的的三角形的面积,然后 * 边数,之后再计算新增加的点所围成的三角形的面积,

之后,用余弦定理和三角函数求出新三角形的底和高,将两部分面积相加即可

 

第一种用:正弦定理和三角函数进行推导的

#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
const double Pi=acos(-1.0);
typedef long long ll;
int main()
{
    double n;
    while(~scanf("%lf",&n))
    {
        double ans=0.5*sin(2.0*Pi/n);
        ans*=n;
        ans+=(2.0*sin(Pi/n)*(1.0-cos(Pi/n)))/2.0;
        printf("%.6lf\n",ans);
    }
    return 0;
}

第二种:用余弦定理和正弦定理进行推导的

#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
const double Pi=acos(-1.0);
typedef long long ll;
int main()
{
    double n;
    while(~scanf("%lf",&n))
    {
        double ans=0.5*sin(2.0*Pi/n);
        ans*=n;
        double tmp = ans;
        tmp+=0.5*(1.0-cos(Pi/n))*sqrt(2.0-2.0*cos (2.0*Pi/n));
        printf("%.6lf\n",tmp);
    }
    return 0;
}

 

posted @ 2021-03-29 19:37  BlackSnow  阅读(73)  评论(0)    收藏  举报