Advertisement
Guest User

D

a guest
Oct 19th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.66 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include<math.h>
  4. int main()
  5. {
  6.     int packs;
  7.     scanf("%d",&packs);
  8.     int i;
  9.     for(i=0;i<packs;i++){
  10.         double x,y,h;
  11.         scanf("%f %f %f",&x,&y,&h);
  12.         double min;
  13.         if(x>y)
  14.             min=y;
  15.         else min=x;
  16.         double med,l,r;
  17.         l=0;
  18.         r=min;
  19.         for(;r-l>0.0005;){
  20.             med=(r+l)/2;
  21.             double a,b;
  22.             a=sqrt(x*x-med*med);
  23.             b=sqrt(y*y-med*med);
  24.             double hnew=(a*b)/(a+b);
  25.             if(hnew<h)
  26.                     r=med;
  27.             else l=med;
  28.         }
  29.     printf("%.4f\n",med);
  30.     }
  31.     return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement