Pages

Thursday 20 December 2012

UVA - 11909 - Soya Milk (Java Solution)

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String m="";
        while((m=br.readLine())!=null){
            StringTokenizer st = new StringTokenizer(m);
            int l=Integer.parseInt(st.nextToken());
            int w=Integer.parseInt(st.nextToken());
            int h=Integer.parseInt(st.nextToken());
            int theta=Integer.parseInt(st.nextToken());
            double d=l*Math.tan(theta*Math.PI/180.0);
            double ans=l*w*((h)-(d*0.5));
            if(d > h){
                ans=0.5*h*h*l*w/d;
            }
            System.out.printf("%.3f mL\n", ans);
        }
    }
}

No comments:

Post a Comment