每天一道算法_6_I Think I Need a Houseboat

今天的题目是I Think I Need a Houseboat如下:DescriptionFred Mapper is considering purchasing some land in Louisiana to build his house on. In the process of investigating the land, he learned that the st

大家好,又见面了,我是全栈君。

今天的题目是I Think I Need a Houseboat

如下:

Description

Fred Mapper is considering purchasing some land in Louisiana to build his house on. In the process of investigating the land, he learned that the state of Louisiana is actually shrinking by 50 square miles each year, due to erosion caused by the Mississippi River. Since Fred is hoping to live in this house the rest of his life, he needs to know if his land is going to be lost to erosion.  



After doing more research, Fred has learned that the land that is being lost forms a semicircle. This semicircle is part of a circle centered at (0,0), with the line that bisects the circle being the X axis. Locations below the X axis are in the water. The semicircle has an area of 0 at the beginning of year 1. (Semicircle illustrated in the Figure.)  

每天一道算法_6_I Think I Need a Houseboat

Input

The first line of input will be a positive integer indicating how many data sets will be included (N). Each of the next N lines will contain the X and Y Cartesian coordinates of the land Fred is considering. These will be floating point numbers measured in miles. The Y coordinate will be non-negative. (0,0) will not be given.

Output

For each data set, a single line of output should appear. This line should take the form of: “Property N: This property will begin eroding in year Z.” Where N is the data set (counting from 1), and Z is the first year (start from 1) this property will be within the semicircle AT THE END OF YEAR Z. Z must be an integer. After the last data set, this should print out “END OF OUTPUT.”

Sample Input

2
1.0 1.0
25.0 0.0

Sample Output

Property 1: This property will begin eroding in year 1.
Property 2: This property will begin eroding in year 20.
END OF OUTPUT.

Hint

1.No property will appear exactly on the semicircle boundary: it will either be inside or outside.  

2.This problem will be judged automatically. Your answer must match exactly, including the capitalization, punctuation, and white-space. This includes the periods at the ends of the lines.  

3.All locations are given in miles.

 

代码如下:

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


public class IThinkINeedaHouseboat {
	public static void main(String args[]){
		double PI = 3.1415926;
		int year = 1;
		float area = 0;
		int year_count = 0;
		Scanner in = new Scanner(System.in);
		int all = in.nextInt();
		int count = all * 2;
		List<Float> list = new ArrayList<Float>();
		while(count > 0){
			count--;
			list.add(in.nextFloat());
		}
		for(int i = 0; i<list.size(); i = i + 2){
			year_count ++;
			area = (float) (PI*(list.get(i) * list.get(i) + list.get(i + 1) * list.get(i + 1))/2);
			for(year = 1; year * 50 < area; year ++){
				
			}
			System.out.println("Property "+ year_count + ": This property will begin eroding in year " + year + ".");
		}
		System.out.println("END OF OUTPUT.");
	}
}

 

作者:jason0539

微博:http://weibo.com/2553717707

博客:http://blog.csdn.net/jason0539(转载请说明出处)

 

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/121384.html原文链接:https://javaforall.cn

【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛

【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...

(0)


相关推荐

  • java date转毫秒_原单位要求退回奖金

    java date转毫秒_原单位要求退回奖金通过自定义的一个子类继承JsonSerializer类然后重写里面的方法publicvoidserialize(Datedate,JsonGeneratorjsonGenerator,SerializerProviderserializerProvider)throwsIOException之后我们在需要将Date转换成long的实体类中添加注解@JsonSe…

  • 三大运营商网络使用频段及随身wifi选用

    三大运营商网络使用频段及随身wifi选用各运营商使用的频段如下 运营商 代数 制式 频段 中国移动 5G NR n41n79 4G TDDLTE B38B39B40B41(18年拿到FDD牌照小规模部署FDDB8) 3G TDSCDMA B34B

    2022年10月20日
  • java学生宿舍管理系统代码(java简单宿舍管理系统)

    分为三大类land.java(登陆界面)system.java(系统管理界面)sql.java(数据库操作,包括连接、断开、增删改查等操作)一、登陆界面及代码主要代码:登陆按钮事件publicvoidactionPerformed(ActionEvente){ //TODOAuto-generatedmethodstub if((JButton)e.ge…

  • checklistbox实现单选

    checklistbox实现单选

  • Java有哪些编程语言

    Java有哪些编程语言Java作为一种年轻具有活力的编程语言,在最近几年是越来越受到市场的欢迎。它作为面向网络的程序设计语言,用来让程序员创建应用程序。Java是个面向对象的语言,由于它自身具备的入门门槛低等优点。那么,Java编程语言具有什么优点?接下来,就跟着千锋重庆Java的小编一起来了解下吧!1.Java语言是简单的Java语言的语法与C语言和C++语言很接近,使得大多数程序员很容易学习和使用。另一方面,Java丢弃了C++中很少使用的、很难理解的、令人迷惑的那些特性,如操作符重载、多继承、自动的强制类型转换。Jav

  • Linux内核简介

    Linux内核简介大纲:理解Linux内核最好预备的知识点Linux内核的特点Linux内核的任务内核的组成部分哪些地方用到了内核机制?Linux进程 Linux创建新进程的机制Linux线程 内核线程地址空间与特权级别    虚拟地址与物理地址  特权级别(Linux的两种状态)    系统调用设备驱动程序、块设备和字符设备网络文件系统模块和热插拔注:本文为《深入Linux内核架构》的学习笔记理解Linux…

发表回复

您的电子邮箱地址不会被公开。

关注全栈程序员社区公众号