`
贝壳水母
  • 浏览: 148055 次
  • 性别: Icon_minigender_1
  • 来自: 广州中低收入人群
社区版块
存档分类
最新评论

Problem1005

    博客分类:
  • POJ
阅读更多
/**
 * 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.) 
 * 
 * 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.
 */

package acm;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Problem1005 {
	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		try {
			int n = Integer.parseInt(br.readLine());
			for (int i = 0; i < n; i++) {
				String s = br.readLine();
				StringTokenizer stk = new StringTokenizer(s);
				double d1 = Double.parseDouble(stk.nextToken());
				double d2 = Double.parseDouble(stk.nextToken());
				double wantKnow = d1*d1+d2*d2;
				double square = 50;
				int count = 1;
				//圆的边长平方-坐标所在矩形的斜边长的平方,若大于等于零则在该情况下已被侵蚀
				while(square/Math.PI*2-wantKnow<0){
					count++;
					square+=50;
				}
				System.out.println("Property "+(i+1)+": This property will begin eroding in year "+count+".");
			}
			System.out.println("END OF OUTPUT.");
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}



题目:原题有个图的,容易理解多了,=_= 我懒,就将就着啦,说,有个人,住的是岛好像,岛的面积呢,每年会因为河流的冲刷,导致面积减少50平方mile,冲刷掉的地方呢,是一个半圆来的,就是以原点为圆心,x轴以上的部分,一开始的时候,是完整的,然后第一年就以半圆的形状扩散出去50平方mile,第二年在这个基础上再扩散50,但形状是保持半圆的,input部分给的是一个坐标,output需要给出这个坐标在哪一年会被侵蚀掉

我的理解:计算每一年最后形成的半圆的半径,如果坐标值对应的矩形的斜边大于该半径,既是还不会侵蚀到啦,就再接着算下一年,直到小于等于半径

PS:到此,我的第一阶段做的题目就结束啦……
接下去还能不能坚持做练习,就……
分享到:
评论

相关推荐

    acm比赛试题

    Problem 1005 本题的标题是“What Is YourGrade?”,它是一道算法设计题目,要求解决一个简单的算法问题。该题目考察了算法设计和实现的知识点,需要使用基本的算法设计方法来解决问题。 知识点: 1. 算法设计 2....

    POJ1005-I Think I Need a Houseboat

    【标题】"POJ1005-I Think I Need a Houseboat" 是一个编程竞赛题目,源自北京大学的在线评测系统POJ(Problem Set of Peking University)。这个题目旨在考验参赛者的算法设计和实现能力,主要涉及数据结构和动态...

    poj1005.zip_北大poj1005

    【标题】"poj1005.zip_北大poj1005"指的是北京大学(北大)在线编程竞赛平台(POJ,Problem Set)上的第1005号算法问题的压缩包资源。这个压缩包可能包含了该问题的题目描述、输入输出样例、数据限制以及提交代码的...

    0-1-knapsack-problem-master (127)c.zip

    0-1 背包问题(0-1 Knapsack Problem)是计算机科学中的一个经典优化问题,尤其在算法设计和分析领域具有重要的地位。它源于实际生活中的物品打包问题,比如我们需要在一个有限容量的背包中放入物品,使得背包中的...

    poj 1005 I Think I Need a Houseboat

    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 ...

    ECNU 1-100 部分AC程序

    ECNU 1-100 部分AC程序 problem list : 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1011 1012 1013 1014 1015 1017 1018 1019 1020 1023 1026 1027 1029 1030 1031 1036 1037 1038 1040 ...

    信息学奥赛一本通(C++版)在线评测系统-答案-1000-1009.docx

    1005:地球人口承载力估计 该题目主要测试了基本的数学运算和浮点数处理,使用浮点数计算地球人口承载力的估计值。该题目考察了基本的C++语法和数学运算。 1006:A+B 问题 该题目主要测试了基本的数学运算,使用两...

    poj 前5题的C 和java代码

    Poj(Problem Online Judge)是一个在线编程竞赛平台,它提供了大量的算法题目供程序员进行训练和挑战。这里的“前5题”指的是poj题库中的最初五道题目,而提供的代码则是针对这些题目的解决方案。 1. **C语言基础*...

    BURNINTEST--硬件检测工具

    - Changes to correct a BurnInTest crash problem on some systems. When the disk and standard RAM tests are run for many hours, BurnInTest may have disappeared with no error message. Release 5.3 ...

    TSP(个人模版)完整版

    TSP,即Traveling Salesman Problem(旅行商问题),是组合优化中的一个经典问题,旨在找到一条最短路径使得一个旅行商可以访问每一个城市恰好一次并最终返回出发城市。这个问题在计算机科学、运筹学以及物流等领域...

    33届ACM杭州区域赛

    例如,1001号问题可能是关于排序或查找,1002号问题可能涉及到图的遍历,1005号问题可能是关于字符串处理的,而1009号问题可能是一个复杂度较高的数学问题。每一道题目都需要参赛者运用他们的知识和经验,快速地找出...

    ZJU_ACM_All_Anwer 搞编程的都知道的浙江大学A 题库.本书 集了所有经 Z 题解集,集合并附 Mathimaticsumerical algorithms 数值算法

    1396 The Umbrella Problem: 2054 简单题 1058 Currency Exchange 简单题 1076 Gene Assembly 简单题 1092 Arbitrage 简单题 1093 Monkey and Banana 简单题 1094 Matrix Chain Multiplication 简单题 ...

    浙江大学ACM题解/ZJU 题型分类

    1396 The Umbrella Problem: 2054 简单题 1058 Currency Exchange 简单题 1076 Gene Assembly 简单题 1092 Arbitrage 简单题 1093 Monkey and Banana 简单题 1094 Matrix Chain Multiplication 简单题 ...

    POJ分类题(按照算法分类)

    7. 1005Biorhythms:涉及生物节律的计算,可能是周期性问题。 8. 1007DNASorting:该问题可能需要使用算法对DNA序列进行排序。 9. 1032Parliament:该题目可能是模拟议会投票或分配问题。 10. 1045BodePlot:这...

    hdu题目分类

    5. **1005 HeroInMaze 广度搜索** - **知识点**: 图的遍历算法、广度优先搜索(BFS)。 - **描述**: 在迷宫中寻找英雄的出路。 - **难度级别**: 中等。 - **解题思路**: 使用队列实现BFS,寻找从起点到终点的路径...

    Foundations for Analytics with Python O-Reilly-2016-Clinton W. Brownley

    Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472. Overview of Chapters Chapter 1, Python Basics We’ll begin by exploring how to create and run a Python script...

Global site tag (gtag.js) - Google Analytics