import java.util.*;
import java.text.*;
public class Main {
public static void main(String [] args)
{
final double eps = 1e-8;
final double pi = Math.acos( - 1.0 );
DecimalFormat ctrl = new DecimalFormat( "0.000000" );
Scanner cin = new Scanner ( System.in);
double r,R,tmp,h,H,V,h1,b,e,mid;
int test = cin.nextInt();
while ( test -- > 0 )
{
r = cin.nextDouble();
R = cin.nextDouble();
H = cin.nextDouble();
V = cin.nextDouble();
if ( r == R)
{
h = V / (pi*r*r);
h = h < H ? h : H;
System.out.println(ctrl.format(h));
continue;
}
h1 = r * H / ( R - r );
b = 0 ; e = H ;
while ( b < e - eps)
{
mid = ( b + e ) * 0.5;
h = mid ;
tmp = ( pi*(h+h1)*(h+h1)*(h+h1)*r*r/ (h1 * h1 *3.0) - pi * (h1)*r * r / 3.0 );
if ( tmp < V )
{
b = mid;
}
else
{
e = mid;
}
}
System.out.println(ctrl.format(b));
}
}
}
posted on 2009-08-18 19:30
Huicpc217 阅读(111)
评论(0) 编辑 收藏 引用 所属分类:
JAVA