Advertisement
erfanul007

crossed ladders

Jan 5th, 2019
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. typedef long long int ll;
  5. typedef unsigned long long int ull;
  6. typedef vector<int> vi;
  7. typedef vector<vi> vvi;
  8. typedef pair<int,int> pii;
  9. typedef vector< pii > vii;
  10. typedef set<int> st;
  11.  
  12. #define pb push_back
  13. #define pob pop_back
  14. #define mp make_pair
  15. #define ff first
  16. #define ss second
  17. #define loop(i,n) for(int i=1; i<=int(n); i++)
  18. #define lps(i,y) for(int i=0; i<int(y); i++)
  19. #define read() freopen("input.txt", "r", stdin)
  20. #define write() freopen("output.txt", "w", stdout)
  21.  
  22. /// Constants
  23. #define eps 1e-9
  24. #define PI acos(-1.0) // 3.1415926535897932
  25.  
  26. int main()
  27. {
  28. read();
  29. int n,i,j;
  30. cin>>n;
  31. double x,y,c,h1,h2,hi,lo,mid,tc;
  32. loop(i,n){
  33. cin>>x>>y>>c;
  34. lo=0.0;
  35. hi=max(x,y);
  36. j=50;
  37. while(j--){
  38. mid=(hi+lo)/2.0;
  39. h1=sqrt((x*x)-(mid*mid));
  40. h2=sqrt((y*y)-(mid*mid));
  41. tc=(h1*h2)/(h1+h2);
  42. if(tc<c)
  43. hi=mid;
  44. else
  45. lo=mid;
  46. }
  47. printf("Case %d: %.10lf\n",i,mid);
  48. }
  49. return 0;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement