Poj Solution 3365

http://poj.org/problem?id=3365

/* @author: */
//����һ�ų�ΪH��Ϊw��ֽ��Ҫ����һ���������Բ����ʹ����Բ�İ뾶����
//���}�����һ����wΪ����Բ���ܳ���һ����H-2RΪ����Բ���ܳ���Ȼ��ȡ���ֵ�ͺ���

import java.util.Scanner;
import java.util.Arrays;
public class Main{
  static double pi=Math.PI;
  static double epx=1e-6;
  
 public static void main(String args[]){
  Scanner sc=new Scanner(System.in);
  double w,h,v1,v2,temp,r,d;   
    while(sc.hasNext()){
     w=sc.nextDouble();
     h=sc.nextDouble();
     if(w==0&&h==0) break;
        if(h>w){temp=h;h=w;w=temp;}   
        v1=h*h*(w-h/pi)/(4.0*pi);   
        d=w/(pi+1);   
        if(d>h+epx){/*�ж�d�Ƿ������*/  
           r=h/2.0;   
          v2=pi*r*r*h;   
        }   
        else v2=pi*w*w*h/(4.0*(pi+1)*(pi+1));   
        System.out.printf("%.3fn",Math.max(v1,v2));   
    }   
   }
  
}  

											
This entry was posted in poj. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *