mhdew

Contest 5_K 2

Feb 27th, 2018
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4. #define in() freopen("Inp.txt", "r", stdin)
  5. #define out() freopen("Oup.txt", "w", stdout)
  6. int a, b;
  7. int m, n;
  8.  
  9. int main()
  10. {
  11. // in();
  12. // out();
  13.  
  14. int t;
  15. char c;
  16. cin>>t;
  17. for(int i=1;i<=t;i++){
  18. scanf("%d %c %d", &m,&c,&n);
  19.  
  20. a=max(m,n);
  21. b=min(m,n);
  22.  
  23. double x, y, z, d, arc;
  24. double ang, per;
  25.  
  26. double l=0.0, h=1000.0;
  27. double mid;
  28.  
  29. for(int j=0;j<100;j++){
  30. mid=(l+h)/2.0;
  31. y=mid;
  32. x=(a*mid)/b;
  33. d=sqrt((x*x)+(y*y));
  34. z=d/2;
  35. ang=acos(((z*z)+(z*z)-(y*y))/(2*z*z));
  36. arc=z*ang;
  37. per=((2*arc)+(2*y));
  38.  
  39. if(per>400.000000){
  40. h=mid;
  41. }
  42. else{
  43. l=mid;
  44. }
  45. }
  46. double big, small;
  47.  
  48. small=mid;
  49. big=sqrt((d*d)-(small*small));
  50.  
  51. // printf("rad=%.6lf ang=%.6lf arc=%.6lf\n", z, ang, arc);
  52.  
  53. printf("%.8lf %.8lf\n", big, small);
  54. }
  55. return 0;
  56. }
Advertisement
Add Comment
Please, Sign In to add comment