bzoj2178: The area of the circle and

Source: Internet
Author: User

Tag: Class line contains a for using output ble simple PAC

Descriptiongive n a circle, ask for its area andInputfirst give a number n,n< = 1000 Next is the N line is the center of the circle, the radius, whose absolute value is less than 1000 of the integerOutputarea and, reserved three decimal placesSimply said is to remove the included circle, to find the circumference of each circle is not covered by other circles of the arc, the corresponding area of the bow and the bow of the chord and the origin of the triangle formed by the direction of the area.
#include <cstdio>#include<cmath>#include<algorithm>using namespaceStd;typedefLong Doubleld;intN;ConstLD Pi=acos (-1. L), _2pi=pi*2;structItv{ld L,r;} is[ -];BOOL operator< (ITV X,itv y) {returnx.l<Y.L;}intip;ld ans=0; LD maxs (LD&a,ld b) {if(a<b) a=b;}structcir{intX,y,r; voidInit () {scanf ("%d%d%d",&x,&y,&r);} BOOL inch(Cir W) {inta=x-w.x,b=y-w.y; returnsqrt (a*a+b*b) +r-1e-7l<W.R; }    BOOLCross (Cir W) {inta=x-w.x,b=y-w.y; returnsqrt (a*a+b*b) <r+W.R; } LD fix (ld x) { while(x<0) x+=_2pi;  while(X&GT;_2PI) x-=_2pi; returnx; }    voidCal (Cir W) {ld xd=W.X-X,YD=W.Y-Y,D=SQRT (xd*xd+yd*yd); LD a=atan2 (YD,XD); LD b=acos ((R*R+D*D-W.R*W.R)/(2*r*d)); LD l=fix (A-B), R=fix (A +b); if(L<r) is[ip++]=(ITV) {L,r}; Else  is[Ip++]= (ITV) {0, r}, is[ip++]=(ITV) {L,_2PI}; } InlinevoidG1 (ld a) {ans+ = (A-sin (a)) *r*R; } InlinevoidG2 (LD l,ld R) {ans+ = ((X+cos (L) *r) * (Y+sin (R) *r)-(X+cos (R) *r) * (Y+sin (l) *R)); }    void Get(){        if(!IP) {ans+=pi*r*r*2; return; } std::sort ( is, is+IP); LD L,r=-1, R1;  for(intI=0, j=0; i<ip;i=j) {R1=r; L= is[I].l; R= is[I].R;  while(j<ip&& is[J].l<=r] Maxs (R, is[J + +].R); if(r1!=-1) G1 (lR1), G2 (r1,l); } G1 ( is[0].L+_2PI-R), G2 (R, is[0].l+_2pi); }}cs[1007];intMain () {scanf ("%d",&N);  for(intI=0; i<n;++i) cs[i].init ();  for(intI=0; i<n;++i) {         for(intj=0; j<n;++j)if(I!=j&&cs[i].inch(Cs[j])) {Cs[i--]=cs[--N];  Break; }    }     for(intI=0; i<n;++i) {IP=0;  for(intj=0; j<n;++j)if(i!=j&&Cs[i].cross (Cs[j]))        {cs[i].cal (cs[j]); } Cs[i].Get(); } printf ("%.3LF", ans/2.); return 0;}

bzoj2178: The area of the circle and

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.