POJ1005 I Think I Need a Houseboat

题目来源:http://poj.org/problem?id=1005

题目大意:

  Fred Mapper考虑在路易斯安那州买一块地来建房子。在调查的过程中,他得知由于密西西比河的侵蚀,路易斯安那州的土地正在以50平方英里的速度退缩。Fred希望能在他新建的房子中度过余生,所以他需要知道他买的土地是否会被侵蚀掉。

  Fred做了一些调查后得知,正在被侵蚀的土地形成一个半圆形,半圆以(0,0)为圆心,被X轴平分,X轴以下为水面。半圆在第1年时面积为0.(半圆如图所示)

输入:第一行为一个正整数表示有多少个数据集(N)。接下来的N行每行含一个X和一个Y表示Fred在考虑的土地位置的笛卡尔坐标。X和Y是以英里为单位的浮点数,Y是非负数,不考虑(0,0)点。(给出的坐标不会恰好在半圆边界上。)

输出:对于每一个数据集,输出占单独一行。输出形式为:“Property N: This property will begin eroding in year Z.”,其中,N为数据集编号(从1开始数),Z为该地会于Z年后(AT THE END OF YEAR Z)被侵蚀。输出的最后加上“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.

 题目的实质可以用如下方程描述:

Pi * (x * X + Y * Y) / 2 <= 50 * (t - 1), 求整数t.

 1 //////////////////////////////////////////////////////////////////////////
 2 //        POJ1005 I Think I Need a Houseboat
 3 //        Memory: 284K        Time: 0MS
 4 //        Language: C++        Result: Accepted
 5 //////////////////////////////////////////////////////////////////////////
 6 
 7 #include <iostream>
 8 
 9 using namespace std;
10 
11 int main(void)
12 {
13     int N;
14     cin >> N;
15     for (int i = 0; i < N; i++) {
16         double x, y;
17         cin >> x >>  y;
18         double tf = 3.14159265 * (x * x + y * y) / 100;
19         int t = tf + 1;
20         cout << "Property "<< i + 1 << ": This property will begin eroding in year " << t << '.' << endl;
21     }
22     cout << "END OF OUTPUT." << endl;
23     system("pause");
24 }
View Code
posted @ 2013-07-30 18:21  小菜刷题史  阅读(307)  评论(0编辑  收藏  举报