[POJ] #1005# I Think I Need a Houseboat : 浮点数运算
Time Limit: 1000MS | Memory Limit: 10000K | |
Total Submissions: 97512 | Accepted: 42430 |
Description
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
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
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
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.
Source
- 河水以每年50平方为单位,呈半圆形扩张侵蚀土地
- 以半圆中心点(0, 0), 建立坐标系
- 给出坐标(x, y),输出该点土地在哪一年会被侵蚀
三. 分析
- 算法核心: 题目较为简单,只需知道基本的求圆面积的几何公式
- 实现细节:
- 圆面积公式
- 结果输出的条件判断
- 浮点类型运算
四. 题解
#include <stdio.h>
#define PI 3.1415927 int main()
{
int area, year, i, count;
float x, y; scanf("%d\n", &count);
for (i = ; i <= count; i++) {
scanf("%f %f\n", &x, &y); area = ; year = ;
while () {
area += ;
if (area > (PI * (x * x + y * y) / )) break;
year++;
}
printf("Property %d: This property will begin eroding in year %ld.\n", i, year);
} printf("END OF OUTPUT.\n");
return ;
}
[POJ] #1005# I Think I Need a Houseboat : 浮点数运算的更多相关文章
- POJ. 1005 I Think I Need a Houseboat(水 )
POJ. 1005 I Think I Need a Houseboat(水 ) 代码总览 #include <cstdio> #include <cstring> #incl ...
- OpenJudge/Poj 1005 I Think I Need a Houseboat
1.链接地址: http://bailian.openjudge.cn/practice/1005/ http://poj.org/problem?id=1005 2.题目: I Think I Ne ...
- [POJ 1005] I Think I Need a Houseboat C++解题
I Think I Need a Houseboat Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 81874 ...
- poj 1005:I Think I Need a Houseboat(水题,模拟)
I Think I Need a Houseboat Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 85149 Acce ...
- poj 1005 I Think I Need a Houseboat
#include <iostream> using namespace std; const double pi = 3.1415926535; int main() { ;; doubl ...
- I Think I Need a Houseboat POJ - 1005
I Think I Need a Houseboat POJ - 1005 解题思路:水题 #include <iostream> #include <cstdio> #inc ...
- I Think I Need a Houseboat POJ - 1005(数学)
题目大意 在二维坐标内选定一个点,问你当洪水以半圆形扩散且每年扩散50单位,哪一年这个点被被洪水侵蚀? 解法 代码 #include <iostream> #include <cst ...
- POJ 1005 解题报告
1.题目描述 2.解题思路 好吧,这是个水题,我的目的暂时是把poj第一页刷之,所以水题也写写吧,这个题简单数学常识而已,给定坐标(x,y),易知当圆心为(0,0)时,半圆面积为0.5*PI*(x ...
- 1005 -- I Think I Need a Houseboat
I Think I Need a Houseboat Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 105186 Acc ...
随机推荐
- js中Number
var numberObject=new Number(1333);numberObject.valueOf(); 1333 var numberObject=new Number(1333);num ...
- Indoor Positioning System & Real time location system
背景 惨痛的背景,正如我前面提到的,参加了公司的一个训练营.刚进来公司的新人,内心充满着对未来的美好憧憬,期待自己能闯出属于自己的天地.更何况,作为一名程序员,无比的希望所有人对自己写得代码或者App ...
- HeadFirst jsp 02 (体系结构)
当请求到来时, 必须有人实例化 servlet, 或者至少建立一个新的线程来处理这个请求. 必须有人调用 servlet 的 doPost()或 doGet()方法. 另外还的有人管理 servlet ...
- Eclipse引用Library失败的问题
整个导入流程严格按照guide的内容操作,但是始终无法导入,设置导入后项目中不出现相关的Library project.在设置完library之后重新打开始始终显示关联错误,就是reference那里 ...
- PHP开发调优clockwork工具
clockwork对于曾经做过C,c++代码调优的工程师并不会陌生,它可以指出代码中的潜在问题,比如内存泄漏,数组越界等.他也可以做profiler动作,指出系统各个函数的执行时间,性能瓶颈到底在哪里 ...
- poj2942 Knights of the Round Table 双连通分支 tarjan
题解:http://blog.csdn.net/lyy289065406/article/details/6756821 讲的很详细我就不多说了. 题目连接:http://poj.org/proble ...
- 设置app的状态栏样式
http://www.jianshu.com/p/9f7f3fa624e7 http://cocoa.venj.me/blog/view-controller-based-status-bar-sty ...
- iOS基础CGAffineTransform的简单使用
CoreGraphics框架中的CGAffineTransform类可用于设定UIView的transform属性,控制视图的缩放.旋转和平移操作: 另称放射变换矩阵,可参照线性代数的矩阵实现方式0. ...
- 四、Emmet:快速编写HTML,CSS代码的有力工具
介绍 Emmet是一个插件,在IDE中安装该插件后即可使用该功能. HTML代码写起来虽简单,但是重复代码很多,Emmet能够存在一种HTML代码简写法(比较类似CSS的选择器写法),比如 div.c ...
- VS启用IIS调试的方法及可能碰到的问题。
经常有这种情况, 开发机本地正常, 但是一旦发布到服务上后, 就出现各种问题. 这是由于开发机和服务器环境不一样造成的, 所以开发时要尽可能的模拟真实性. 这时候, VS的这个功能就帮大忙了. 如何 ...