Advertisement
momo2345

crossed ledder

Sep 16th, 2020
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.73 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define suni ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
  4. #define endl "\n"
  5. #define mn int main()
  6. #define frac() cout.unsetf(ios::floatfield);cout.precision(6);cout.setf(ios::fixed,ios::floatfield);
  7. typedef long long ll;
  8. mn
  9. {
  10.     suni;
  11.     int t; cin>>t;
  12.     for(int i=1;i<=t;i++){
  13.         double x,y,c;
  14.         cin>>x>>y>>c;
  15.         double l=0,r=min(x,y);
  16.         for(int i=1;i<=100;i++){
  17.             double d=(l+r)/2.0;
  18.             double h1=sqrt((x*x)-(d*d));
  19.             double h2=sqrt((y*y)-(d*d));
  20.             double h=((h1*h2)/(h1+h2));
  21.             if(h>c) l=d;
  22.             else r=d;
  23.         }
  24.         frac();
  25.         cout<<"Case "<<i<<": "<<l<<endl;
  26.     }
  27. }
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement