Test instructions: The area where the intersection of two equal rings is asked .... Simple computational geometry + repulsion principle? The sector area formula was wrongly adjusted for half a day 2333333333 This problem is not difficult ... But from the seniors there are a few points about the code specification of the problem ... I heard that seniors in Beijing regional competition when the PI was defined wrong a result has been the lesson of WA .... Write ACOs (-1) in the future. Local variables and global variables because "how to think about its variable name is not good for the whole person," it became the same ... By the seniors gave bad reviews. Oh, yes! Another is to discover the Cmath library has a wonderful function called Y1 ... —————————————————————————————————————————————— Even CE hint Error:pow (int,int) is ambiguous It seems that my mastery of language is still not good ..... "is a function declared as POW (double, double) You must pass two double arguments in. But you can also pass int, int will transform to double, but C + + has overloads. Declared two functions pow (double, double), pow (long Long, double), you pass two int go in the compiler does not know whether to convert int to double or long long " "The solution is to convert int to double (XXX) or long long (XXX)" can also be simple rough xxx.0
(Int,int) (double,int)? (double,double)
C + + language: The highlighted code is provided by the germination net #include <iostream> #include <cmath> #include <iomanip> 04 using namespace Std; 06 T,TT int; Rr,rr,x11,x22,y11,y22 int; Double ans; Ten const Double Pi=acos (-1); one const double c=10e-6; Double area (int x1,int y1,int x2,int y2,int r,int R); int main () 14 { cin>>t; tt=t; (t--) 18 { cin>>rr>>rr; cin>>x11>>y11>>x22>>y22; Ans=area (X11,Y11,X22,Y22,RR,RR) -2*area (X11,Y11,X22,Y22,RR,RR) + (X11,Y11,X22,Y22,RR,RR); cout<< "Case #" <<tt-t<< ":" <<fixed<<setprecision (6) <<ans<<endl; 25} return 0; 27} Double area (int x1,int y1,int x2,int y2,int r,int R) 29 { Double D; Double a,a; Double St; D=sqrt (Pow (x1-x2,2) +pow (y1-y2,2)); if (d>=r+r) return 0; if (R-r>=d) Panax Notoginseng return r*r*pi; A=acos ((r*r+d*d-r*r)/(2.0*d*r)); A=acos ((r*r+d*d-r*r)/(2.0*d*r)); St=r*d*sin (A); a=a*2; a=a*2; /2.0-st return (A*R*R+A*R*R); 44}
|