北大ACM试题1005

题目比较简单,基本就是求半圆的面积。。。最后提交的时候记得要把import提交上去,要把类名改成Main,要不编译通不过哦~~

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main_1005_Semicircle {

public static void main(String[] args) throws IOException {
Scanner cin = new Scanner(System.in);
int n = cin.nextInt();
cin.nextLine();
List<String> input = new ArrayList<String>();
while(n > 0){
input.add(cin.nextLine());
n–;
}
cin.close();

for(int i=0;i<input.size();i++){
String s = input.get(i);
String[] ss = s.split(” “);
double a = Double.parseDouble(ss[0]);
double b = Double.parseDouble(ss[1]);
double c = Math.sqrt(a*a + b*b);
double area = Math.PI * c * c / 2;
int year = (int)(area / 50) + 1;
System.out.println(“Property “+(i+1)+
“: This property will begin eroding in year “+year+”.”);
}
System.out.println(“END OF OUTPUT.”);
}

}

点赞