Codeforces Round #357 (Div. 2) E Computational geometry

Source: Internet
Author: User
Tags acos

The legend does CF does not fill the question equal to did not do so the first time to fill ... This time CF did not make the description of De D The magic to now also did not understand so only to fill the E

Each div2 is hack before two or three questions finally hit a hack after the third question ... Hope that the future will be better and sooner. At least become a blue name:)

E Test instructions There's a cockroach who's going to kill it gives the cockroach the coordinates of the speed of the man's aim time and give some shadows (round and give coordinates and radii) if the cockroach moves into the shadow, it will stop immediately. The cockroach who doesn't hit the shadows asks if it's not killed. The direction of the cockroach's movement is random.

It's important to note that the cockroach only goes straight in one direction.

So we're going to judge every shadow circle if we can get to the point of view. The Atan is used here to achieve atan (x, y) returns the angle of the x axis from the origin to X, y of the planar Cartesian coordinate system

It should be noted that when the two circles intersect to a certain extent, it is necessary to determine whether the maximum angle will be reduced when the maximum value is reached.

We can draw an angle range for every shadow we can reach. Finally, we should merge each interval.

The angle of <-pi or >PI may be generated after Angle+-ang this time we split it into two copies in the leftmost part at the right

It's better to make a sequence and then judge.

I wrote the wrong letter when I acos the problem ... Ran all the way to the test79 just WA off ... Is.. Doubility

#include <stdio.h> #include <string.h> #include <algorithm> #include <map> #include <math.h    > #include <iostream> #include <queue>using namespace std;double x0,yy,v,t;int n;double pi;struct node{ Double x,y,r;}; Node A[100050];int w;struct no{double k1,k2;}; No b[100050];d ouble dis (double x1,double y1,double x2,double y2) {return sqrt ((x1-x2) * (X1-X2) + (y1-y2) * (Y1-y2));}    Double r;void check (int x) {if (DIS (a[x].x,a[x].y,x0,yy) >= (R+A[X].R)) return;    Double D=dis (A[X].X,A[X].Y,X0,YY);    -pi<angel<pi double angle=atan2 (A[X].X-X0,A[X].Y-YY);    Double r1=sqrt (D*D-A[X].R*A[X].R);    Double ang;    if (r1<r) {ang=asin (a[x].r/d);    } else {Ang=acos (D*D+R*R-A[X].R*A[X].R)/(2*d*r));    } double Al=angle-ang;    Double Ar=angle+ang;        if (al>=-pi-0.000000000001&&ar<=pi+0.000000000001) {w++;        B[w].k1=al;    B[w].k2=ar;        } else if (al<-pi-0.000000000001) {w++;B[w].k1=-pi;        B[w].k2=ar;        w++;        b[w].k1=pi+ (AL+PI);    B[w].k2=pi;        } else if (ar>pi+0.000000000001) {w++;        B[w].k1=al;        B[w].k2=pi;        w++;        B[w].k1=-pi;    b[w].k2=-pi+ (AR-PI); } return;    int CMP (no a,no b) {return a.k1<b.k1; return A.K2&GT;B.K2;}    int main () {while (cin>>x0>>yy>>v>>t) {Pi=acos (-1);    cin>>n;    BOOL Ok=false;        for (int i=1;i<=n;i++) {scanf ("%lf%lf%lf", &AMP;A[I].X,&AMP;A[I].Y,&AMP;A[I].R);        if ((x0-a[i].x) * (x0-a[i].x) + (YY-A[I].Y) * (YY-A[I].Y) &LT;=A[I].R*A[I].R) {ok=true;    }} r=v*t;    if (ok==true) {printf ("1.00000000000\n");        } else {w=0;        for (int i=1;i<=n;i++) {check (i);        } if (w==0) {printf ("0.00000000000\n");            } else {sort (b+1,b+1+w,cmp);            Double ans=0;            Double Q=-pi;   for (int i=1;i<=w;i++)         {Double l=b[i].k1;                Double r=b[i].k2;                    if (r>q) {double ll;                    if (l>q) {ll=l;                    } else {ll=q;                    } if (r-ll>0) ans+= (R-LL);                s=0;            } else continue;        } printf ("%.11f\n", ans/(2*PI)); }    }}}

  

Codeforces Round #357 (Div. 2) E Computational geometry

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.