Editorial for Bedao Grand Contest 08 - GEOMETRY
Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.
Submitting an official solution before solving the problem yourself is a bannable offence.
Code mẫu
#include <bits/stdc++.h> #define ld long double using namespace std; ld pi=3.1415926535897932384626433; int test; ld r1,r2,al,x,rr,beta,beta1,haf,s,res; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); freopen("GEOMETRY.INP","r",stdin); freopen("GEOMETRY.OUT","w",stdout); cin>>test; while(test--){ cin>>r1>>r2; al=atan((r1+r2)/r1); x=2.0000*r1*cos(al); rr=r1*r1; beta=acos((2.000*rr-x*x)/(2.000*rr)); beta1=pi/2.000-beta; haf=(r1+r1+x)/2.000; s=sqrt(haf*(haf-r1)*(haf-r1)*(haf-x)); res=r1*(r1+r2)-s-beta1*rr-(pi/2.000-al)*r2*r2; res=res/2.000; cout<<setprecision(4)<<fixed<<res<<'\n'; } }
Comments