Advertisement
momo2345

triangle

Sep 12th, 2020
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.95 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define frac() cout.unsetf(ios::floatfield);cout.precision(10);cout.setf(ios::fixed,ios::floatfield);
  4. int main(){
  5.     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  6.     int t;
  7.     cin>>t;
  8.     for(int j=1;j<=t;j++){
  9.         double ab,bc,ac,rr;
  10.         cin>>ab>>ac>>bc>>rr;
  11.         double l=0,r=ab;
  12.         double ad;
  13.         for(int i=1;i<=100;i++){
  14.              ad=(l+r)/2.0;            //8.134 9.098 7.123 5.10
  15.             double x=ad/ab;
  16.             double ae=ac*x;
  17.             double de=bc*x;
  18.             double pabc=(ab+bc+ac)/2.0;
  19.             double pade=(ad+ae+de)/2.0;
  20.             double Aabc=sqrt(pabc*(pabc-ab)*(pabc-bc)*(pabc-ac));
  21.             double Aade=sqrt(pade*(pade-ad)*(pade-de)*(pade-ae));
  22.             double Atrap=Aabc-Aade;
  23.             if(rr<(Aade/Atrap)) r=ad;
  24.             else l=ad;
  25.         }
  26.         frac();
  27.         cout<<"Case"<<" "<<j<<":"<<" "<<ad<<"\n";
  28.     }
  29.  
  30. }
  31.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement