Pages

Thursday 27 December 2012

UVA - 10209 - Is This Integration ? (Java Solution)

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

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuffer sb=new StringBuffer("");
        String m="";
        while((m=br.readLine())!=null){
            double a=Double.parseDouble(m);
            double areaOfRect=a*a;
            double x = areaOfRect * (1 - Math.sqrt(3) + Math.PI / 3); 
            double y = areaOfRect * (2 * Math.sqrt(3) - 4 + Math.PI / 3); 
            double z = areaOfRect * (4 - Math.sqrt(3) - 2 * Math.PI / 3);
            String temp=String.format("%.3f %.3f %.3f\n", x,y,z);
            sb.append(temp);
        }
        System.out.print(sb);
    }

}

No comments:

Post a Comment