Http://hzwer.com/6330.html
#include <cstdio> #include <cmath> #include <algorithm>using namespace std; #define N 100001#define EPS 0.00000001typedef Double Db;const db Pi=acos ( -1.0); struct point{db x, y;} P[n<<2],bao[n<<2];bool operator < (point A,point b) {return fabs (a.x-b.x) >=EPS?a.x<b.x:a.y< B.Y;} typedef point Vector; Vector operator + (vector a,vector b) {return (vector) {a.x+b.x,a.y+b.y};} Vector operator-(vector a,vector b) {return (vector) {a.x-b.x,a.y-b.y};} Vector Rotate (vector a,db rad) {return (vector) {A.x*cos (RAD)-a.y*sin (RAD), A.x*sin (RAD) +a.y*cos (RAD)}; DB SQR (db x) {return x*x;} DB Cross (Vector A,vector b) {return a.x*b.y-a.y*b.x;} DB Dist (point A,point b) {return sqrt (SQR (a.x-b.x) +SQR (A.Y-B.Y));} int n,m,en;db A,b,r,mx,my,jiao,ans;int Main () {scanf ("%d%lf%lf%lf", &n,&b,&a,&r); a-= (2.0*r); b-= (2.0 *R); for (int i=1;i<=n;++i) {scanf ("%lf%lf%lf", &mx,&my,&jiao); P[++m]=rotate (Vector) {A*0.5,b*0.5},jiao) + (point) {mx,my}; P[++m]=rotate (Vector) {(-a) *0.5,b*0.5},jiao) + (point) {mx,my}; P[++m]=rotate (Vector) {a*0.5, (-B) *0.5},jiao) + (point) {mx,my}; P[++m]=rotate (Vector) {(-a) *0.5, (-B) *0.5},jiao) + (point) {mx,my}; }sort (p+1,p+1+m); for (int. i=1;i<=m;++i) {while (En>1&&cross (Bao[en]-bao[en-1],p[i]-bao[en]) <=0.0) --en; Bao[++en]=p[i]; }int t=en;for (int i=m-1;i;--i) {while (En>t&&cross (Bao[en]-bao[en-1],p[i]-bao[en]) <=0.0)--en; Bao[++en]=p[i]; }for (int i=2;i<=en;++i) ans+=dist (Bao[i-1],bao[i]);p rintf ("%.2f\n", Ans+dist (Bao[en],bao[1]) +PI*r*2.0); return 0 ;}
Compute geometry "convex hull" bzoj2829 credit card convex package