Advertisement
sajid161

19:3

May 16th, 2021
974
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.82 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. #define fraction() cout.unsetf(ios::floatfield);cout.precision(10);cout.setf(ios::fixed,ios::floatfield);
  3. using namespace std;
  4. const double spc=1e-6;
  5. int main()
  6. {
  7.     int t;
  8.     cin>>t;
  9.     for(int tc=1;tc<=t;tc++)
  10.     {
  11.         double ab,ac,bc,ra,ae,de,abc,ade,p1,p2,bdec;
  12.         cin>>ab>>ac>>bc>>ra;
  13.         p1=(ab+ac+bc)/2;
  14.         abc=sqrt(p1*(p1-ab)*(p1-ac)*(p1-bc));
  15.         double l=0,r=ab;
  16.         for(int i=0;i<100;i++)
  17.         {
  18.             double mid=(l+r)/2;
  19.             ae=(mid/ab)*ac;
  20.             de=(mid/ab)*bc;
  21.             p2=(mid+ae+de)/2;
  22.             ade=sqrt(p2*(p2-ae)*(p2-de)*(p2-mid));
  23.             bdec=abc-ade;
  24.             if((ade/bdec)>ra) r=mid;
  25.             else l=mid;
  26.  
  27.         }
  28.         fraction();
  29.         cout<<"Case "<<tc<<": "<<l<<endl;
  30.  
  31.     }
  32.  
  33. }
  34.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement