#include <bits/stdc++.h>
using namespace std;
const int maxn = 5E2 + 10;
const double PI = acos(-1);
struct Point
{
double x, y;
Point(double x = 0, double y = 0): x(x), y(y) {}
};
typedef Point Vector;
typedef vector<Point> Polygon;
Vector operator +(Vector A, Vector B)//
{
return Vector(A.x + B.x, A.y + B.y);
}
Vector operator -(Point A, Point B)//
{
return Vector(A.x - B.x , A.y - B.y);
}
Vector operator *(Vector A, double p)//
{
return Vector(A.x * p, A.y * p);
}
Vector operator /(Vector A, double p)//
{
return Vector(A.x / p, A.y / p);
}
bool operator <(const Point &a, const Point &b)//
{
return a.x < b.x || (a.x == b.x && a.y < b.y);
}
const double eps = 1e-10;
int dcmp(double x)//
{
if (fabs(x) < eps) return 0;
else return x < 0 ? -1 : 1;
}
double Cross(Vector A, Vector B)//
{
return A.x * B.y - A.y * B.x;
}
double Area2(Point A, Point B, Point C) //
{
return fabs(Cross(B - A, C - A)) / 2;
}
Vector Rotate(Vector A, double rad) //
{
return Vector(A.x * cos(rad) - A.y * sin(rad), A.x * sin(rad) + A.y * cos(rad));
}
double torad(double deg)
{
return deg / 180 * PI;
}
int n;
double r, deg;
Point P[maxn];
Point read_point()
{
scanf("%lf", °);
double rad = torad(deg);
return Point(r * cos(rad), r * sin(rad));
}
int main(int argc, char const *argv[])
{
while (~scanf("%d%lf", &n, &r) && n + r)
{
for (int i = 0; i < n; i++)
P[i] = read_point();
double sum = 0;
for (int i = 0; i < n; i++)
for (int j = i + 1; j < n; j++)
for (int k = j + 1; k < n; k++)
sum += Area2(P[i], P[j], P[k]);
printf("%lld\n", (long long)(sum + 0.5));
}
return 0;
}
三重循环暴力枚举即可。
可以使用容斥做,这个讲得好:http://blog.csdn.net/shimmer_/article/details/38613079