[POJ 1005] I Think I Need a Houseboat C++解题
Time Limit: 1000MS | Memory Limit: 10000K | |
Total Submissions: 81874 | Accepted: 35368 |
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.
解决思路
这是一道很简单的计算几何题,本质就是计算点是否在指定的半圆内。
源码
/*
poj 1000
version:1.0
author:Knight
Email:S.Knight.Work@gmail.com
*/ #include<cstdio>
#include<cmath>
using namespace std;
const double PI = 3.1415926;
int main(void)
{
double S;//被腐蚀陆地的总面积
double r;//腐蚀陆地的半径
int i,j;
int T;
double X,Y;//Fred的坐标
double Distance;//Fred据坐标原点的距离
scanf("%d", &T);
for (i=; i<=T; i++)
{
scanf("%lf%lf", &X, &Y);
Distance = sqrt(X * X + Y * Y);
S = 0.0;
for (j=; ; j++)
{
S += 50.0;
r = sqrt( * S / PI);
if (r >= Distance)
{
break;
}
}
printf("Property %d: This property will begin eroding in year %d.\n", i, j);
}
printf("END OF OUTPUT.\n");
return ;
}
[POJ 1005] I Think I Need a Houseboat C++解题的更多相关文章
- 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(水题,模拟)
I Think I Need a Houseboat Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 85149 Acce ...
- [POJ] #1005# I Think I Need a Houseboat : 浮点数运算
一. 题目 I Think I Need a Houseboat Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 97512 ...
- 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 ...
随机推荐
- jsoup爬虫,项目实战,欢迎收看
import com.mongodb.BasicDBObject import com.mongodb.DBCollection import org.jsoup.Jsoup import org.j ...
- jetty启动(server-connector-handle-start-join)
import java.io.File; import java.io.IOException; import java.util.Map; import javax.servlet.ServletE ...
- 关于SQL Server索引密度的知识
文章主要描述的是SQL Server索引密度(Index Densities),当一个查询的SARG 的值直到查询运行时才得以知晓,或是SARG是一个关于索引的多列时,SQL Server才使用为索引 ...
- python 之正则表达式
一.正则表达式 首先,我们需要感性的了解下什么是正则表达式,简单的是说“正则表达式”就是一个“表达式”,更准确定义是:“用一个简洁的方法来实现对“一组字符串”的表达式. 最终目的就是实现“一行胜千言” ...
- mysql-单表操作
mySql单表操作主要有一下内容: 1.查询:查询又分为几种,范围查询,模糊查询.空值查询.多条件查询 查询的语句格式为:SELECT 字段 1,字段 2,字段 3...FROM 表名 WHERE 条 ...
- 【TensorFlow入门完全指南】基本操作
众所周知我暂时弃掉了那个音乐生成的坑,原因是我的代码写得还不够纯熟…… 现在我找到了一个项目,用来从代码基础开始补起,同时写下学习笔记. 项目地址:https://github.com/aymeric ...
- python爬虫之路——基本文件操作
介绍python如何打开文件和读取数据 新建TXT文档,为追加模式: f=open('c;/wendang/demo.txt','a+') content="abcdefg123456789 ...
- matlab启动
直接在命令行输入matlab会报错 用这两个命令没问题 sudo /usr/local/MATLAB/R2013a/bin/matlab sudo /usr/local/MATLAB/R2013a/b ...
- Java压缩字符串工具类
StringCompressUtils.java package javax.utils; import java.io.ByteArrayInputStream; import java.io.By ...
- PMD 编译 语法分析 词法分析 抽象语法树
编译原理 163 课堂 http://mooc.study.163.com/learn/-1000002001?tid=1000003000#/learn/content?type=detail&am ...