[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 ...
随机推荐
- CollectionBase类
在命名空间System.Collections下的CollectionBase类 The CollectionBase class exposes the interfaces IEnumerable ...
- leetcode:Intersection of Two Linked Lists(两个链表的交叉点)
Write a program to find the node at which the intersection of two singly linked lists begins. For ex ...
- 【转】Android Gson的使用
Android Gson 2014 年 05 月 22 日 android 目前的客户端大都有和服务端进行交互,而数据的格式基本就是json了,于是在Android开发中就经常用到json解析,方便的 ...
- 网易新闻页面信息抓取 -- htmlagilitypack搭配scrapysharp
最近在弄网页爬虫这方面的,上网看到关于htmlagilitypack搭配scrapysharp的文章,于是决定试一试~ 于是到https://www.nuget.org/packages/Scrapy ...
- 5个缺失的 JavaScript 数字格式化函数
/** 下面两个函数都能对浮点数进行四舍五入,保留小数点后两位 **/ function CurrencyFormatted(amount) { var i = parseFloat(amount); ...
- 权限控制框架Shiro简单介绍及配置实例
Shiro是什么 http://shiro.apache.org/ Apache Shiro是一个非常易用的Java安全框架,它能提供验证.授权.加密和Session控制.Shiro非常轻量级,而且A ...
- iOS富文本(二)初识Text Kit
概述 Text Kit 是建立在Core Text上的文本布局系统,虽然没有Core Text那么强大的文本处理功能,但是对于大多数常见的文本布局用Text Kit能够很简单的实现,而不是用Core ...
- 【英语】Bingo口语笔记(48) - 关于春节的表达
- Hadoop2.6.0完全分布式安装
本文地址:http://www.cnblogs.com/myresearch/p/hadoop-full-distributed-operation.html,转载请注明源地址. 我这边是使用了两台主 ...
- file的getPath getAbsolutePath和getCanonicalPath的不同
file的这几个取得path的方法各有不同,下边说说详细的区别 概念上的区别:(内容来自jdk,个人感觉这个描述信息,只能让明白的人明白,不明白的人看起来还是有点难度(特别试中文版,英文版稍好些)所以 ...