这道题直接暴力枚举,把所有三角形的面积加起来就行了。
#include <iostream>
#include <fstream>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <vector>
using namespace std;
const double pi=2*acos(0.0);
int n;
double r;
struct point
{
double x,y;
point(double x,double y):x(x),y(y){}
};
point operator-(point a,point b){return point(a.x-b.x,a.y-b.y);}
double cross(point a,point b){return a.x*b.y-a.y*b.x;}
double area(point a,point b){return fabs(cross(a,b))/2;}
vector<point> v;
double torad(double x)
{
return x/180*pi;
}
int main()
{
freopen("in.txt","r",stdin);
while(cin>>n>>r)
{
if(!n&&r==0) break;
v.clear();
double deg;
for(int i=0;i<n;i++)
{
cin>>deg;
deg=torad(deg);
v.push_back(point(r*cos(deg),r*sin(deg)));
}
double ans=0;
for(int i=0;i<n;i++)
for(int j=i+1;j<n;j++)
for(int k=j+1;k<n;k++)
{
ans+=area(v[i]-v[j],v[i]-v[k]);
}
printf("%.0f\n",ans);
}
return 0;
}