计算几何专项:UVa 11186
2013-03-17 21:42
337 查看
这道题直接暴力枚举,把所有三角形的面积加起来就行了。
#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; }
相关文章推荐
- 计算几何专项:UVa 10556
- 计算几何专项:UVa 10585
- 计算几何专项:UVa 10245
- 计算几何专项:UVa 11072
- 计算几何专项:UVa 10084
- 计算几何专项:UVa 10566
- 计算几何专项:UVa 10674
- 计算几何专项:UVa 12301
- 计算几何专项:UVa 11265
- 计算几何专项:UVa 12307
- 计算几何专项:UVa 588
- 计算几何专项:UVa 11437
- 计算几何专项:UVa 754
- 计算几何专项:UVa 10522
- 计算几何专项:UVa 11817
- 计算几何专项:UVa 11524
- 计算几何专项:UVa 10439
- 计算几何专项:UVa 811
- uva 1531 & poj 1518 Problem Bee(几何计算+贪心)
- UVA_393_Doors_(计算几何基础+最短路)