`
mycream
  • 浏览: 54214 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

POJ 1005 I Think I Need a Houseboat

 
阅读更多

POJ 1005 I Think I Need a Houseboat

 

晕死,这道题居然卡在了英语上。在讨论区有人给出了大致的意思

 写道
大体意思:
半圆表示一块面积可扩展的区域,开始时,面积是0,在(0,0)处开始以每年50平方米的速度同样呈半圆扩展,输入一个正整数N,然后输入N对坐标,对于每一对坐标值:求出面积扩展到该点的年数,坐标值单位为米。

 有了中文帮助,直接秒杀此题。唉,英语啊~~~

代码如下:

import java.util.Scanner;

public class Main {
	public int calcYear(double x, double y) {
		double r = x * x + y * y;
		double s = r * Math.PI / 2d / 50d;
		return (int) Math.ceil(s);
	}

	public void run() throws Exception {
		Scanner scan = new Scanner(System.in);
		int input = scan.nextInt();
		for (int i = 0; i < input; i++) {
			int year = calcYear(scan.nextDouble(), scan.nextDouble());
			System.out.println("Property " + (i + 1) + ": This property will begin eroding in year " + year + ".");
		}
		System.out.println("END OF OUTPUT.");

	}

	public static void main(String[] args) {
		Main m = new Main();
		try {
			m.run();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
 
0
0
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics