/**
* 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:到此,我的第一阶段做的题目就结束啦……
接下去还能不能坚持做练习,就……
分享到:
相关推荐
《Approaching (Almost) Any Machine Learning Problem》
Wicked Environmental Problem
The C10K problem
master page search problem viewdata js
Title: Computer-Based Problem Solving Process Author: Teodor Rus Length: 350 pages Edition: 1 Language: English Publisher: World Scientific Publishing Company Publication Date: 2015-05-30 ISBN-10: ...
MCM 2012年 problem A problem B problem C 枪手论文
Problem Solving with C++, Global Edition by Walter Savitch (author) (Author) Pages:1117 出版社: Pearson Education Limited; 10th edition edition (November 20, 2017) Language: English ISBN-10: ...
8D is a problem-solving methodology for product and process improvement. It is structured into eight disciplines, emphasizing team synergy. The team as whole is better and smarter than the quality sum...
Problem solving with C++
On a problem of formal logic___ramsey___1928On a problem of formal logic___ramsey___1928On a problem of formal logic___ramsey___1928On a problem of formal logic___ramsey___1928On a problem of formal ...
Problem Arrangement zoj 3777
node-problem-detector 镜像包 v0.8.7 版本
Java An Introduction to Problem Solving and Programming全英文,第六版,共享给大家,希望有需要的朋友喜欢
算法设计里关于taxi problem的C语言代码
this is the machine problem solution for operating system class
java xml realworld problem,java xml 技术 详细说明明
HDOJ Problem 1001 C++版
Inverse Problem Theory and Methods for Model Parameter Estimation - A. Tarantola(牛叉)
The problem is to find an algorithm to ensure that the loyal generals will reach agreement. It is shown that, using only oral messages, this problem is solvable if and only if more than two-thirds of...
flow shop problem GA算法 详细代码标注