fork download
  1. #include <bits/stdc++.h>
  2.  
  3. #define lp(moh,k,n) for (long long moh=k ; moh<n ; moh++)
  4. #define lp0(moh,n) for(long long moh=0;moh<n;moh++)
  5.  
  6. #define ll long long
  7. #define mxint INT_MAX
  8. #define mnint INT_MIN
  9. #define it(itr) map<int,int>::iterator itr
  10. #define stp(n) fixed<<setprecision(n)
  11.  
  12. using namespace std;
  13. void flash(){
  14. cin.tie(0);
  15. cin.sync_with_stdio(0);
  16. cout.tie(0);
  17. cout.sync_with_stdio(0);
  18. }
  19. double sinn(double s);
  20. double asinn(double s);
  21. int main()
  22. {
  23. //freopen("offer.in","r",stdin);
  24. //freopen("keyboard.in", "r", stdin);
  25. flash();
  26. double pi =3.14159265359;
  27. double r1,r2;
  28. int t;
  29. cin>>t;
  30. while(t--){
  31. cin>>r1>>r2;
  32. double w=sqrt( (r1*r1)+(r1+r2)*(r1+r2) );
  33. //cout<<w;
  34. double s2=asinn(r1/w);
  35. //cout<<s2;
  36. double s1=asinn((r1+r2)/w);
  37. //cout<<s1<<" "<<s2;
  38. double as2=(pi*r2*r2*s2)/360;
  39. double Sinc=180-(2*s1);
  40. double ASinc=((pi*r1*r1*Sinc)/360)-(.5*r1*r1*sinn(Sinc));
  41.  
  42. double as1=( (pi*r1*r1)/4 )-ASinc;
  43. double AT=.5*r1*(r1+r2);
  44. double sout=AT-(as2+as1);
  45. cout<<stp(10)<<sout<<'\n';
  46. }
  47. }
  48. //------------------------------------------
  49. double asinn(double s){
  50. double pi =3.14159265359;
  51. double ret=asin(s);
  52. double val = (ret * 180) / pi;
  53. return val;
  54. }
  55. //------------------------------------------
  56. double sinn(double s){
  57. double pi =3.14159265359;
  58. return sin(s*(pi/180));
  59. }
Success #stdin #stdout 0.01s 5532KB
stdin
2
10 5
5 10
stdout
1.7565653168
2.3212820551