"Compute geometry" "Convex hull" bzoj2829 credit card convex bag

Source: Internet
Author: User
Tags cos

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.