POJ1005 I Think I Need a Houseboat
水题,只要会算半圆面积就能解。其中计算面积可以用Math类中的方法,当时编写图简单就没有使用。
double area = Math.PI * (Math.pow(x,2)+Math.pow(y,2)) / 2.0;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner cin=new Scanner(System.in);
int count = cin.nextInt();
cin.nextLine();
for(int idx = 0;idx < count;idx++){
double x = cin.nextDouble();
double y = cin.nextDouble();
double area = 0.5 * 3.1415926 * (x*x+y*y);
int year = (int)(area/50.0+1);
System.out.println("Property "+(idx+1)+": This property will begin eroding in year "+year+".");
}
System.out.println("END OF OUTPUT.");
}
}