posts - 2,comments - 1,trackbacks - 0
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  / 3.0  );
                
if ( tmp < V )
                {
                    b 
= mid;
                }
                
else
                {
                    e 
= mid;
                }
            }
            System.
out.println(ctrl.format(b));
        }
    }

}

posted on 2009-08-18 19:30 Huicpc217 阅读(100) 评论(0)  编辑 收藏 引用 所属分类: JAVA

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理