Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include<math.h>
- int main()
- {
- int packs;
- scanf("%d",&packs);
- int i;
- for(i=0;i<packs;i++){
- double x,y,h;
- scanf("%f %f %f",&x,&y,&h);
- double min;
- if(x>y)
- min=y;
- else min=x;
- double med,l,r;
- l=0;
- r=min;
- for(;r-l>0.0005;){
- med=(r+l)/2;
- double a,b;
- a=sqrt(x*x-med*med);
- b=sqrt(y*y-med*med);
- double hnew=(a*b)/(a+b);
- if(hnew<h)
- r=med;
- else l=med;
- }
- printf("%.4f\n",med);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement