`
翼若云
  • 浏览: 6005 次
  • 性别: Icon_minigender_1
  • 来自: 北京
最近访客 更多访客>>
社区版块
存档分类
最新评论

POJ1005 I Think I Need a Houseboat

    博客分类:
  • poj
阅读更多

水题,只要会算半圆面积就能解。其中计算面积可以用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.");
    }
}
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics