[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 ...
随机推荐
- I/O操作总结(一)
所谓IO,也就是Input与Output的缩写.在java中,IO涉及的范围比较大,这里主要讨论针对文件内容的读写 其他知识点将放置后续章节(我想,文章太长了,谁都没耐心翻到最后) 对于文件内容的操作 ...
- vue2.0:(九)、外卖App弹窗部分星星评分
本篇是星星评分部分,先上代码: 1.header.vue: <template> <transition name="fade"> & ...
- Mysql order by 排序 varchar 类型数据
Mysql order by 排序 varchar 类型数据 varchar 类型字段排序, 会將数字当成字符串来处理. 排序规则一般是从左到右一位位来比较. +0之后 就转化成INT 类型排序 ...
- python+selenium之验证码的处理
对于web应用来说,大部分的系统在用户登录时都要求用户输入验证码.验证码的类型很多,有字母数字的,有汉字的.甚至还有需要用户输入一道算术题的答案的.对于系统来说,使用验证码可以有效地防止采用机器猜测方 ...
- MovieReview—Coco(寻梦环游记)
Dream & Family The protagonist in the movie is hard to choose between family and dream. ...
- 使用ErrorProvider组件验证文本框输入
实现效果: 知识运用: ErrorProvider组件的BlinkStyle属性 //指示错误图标的闪烁时间 public ErrorBlinkStyle BlinkStyle{ get;set; } ...
- python_101_类方法
class Dog(object): n=333 name='小虎子' def __init__(self,name): self.name=name @classmethod def eat(sel ...
- kubernetes监控-prometheus(十六)
监控方案 cAdvisor+Heapster+InfluxDB+Grafana Y 简单 容器监控 cAdvisor/exporter+Prometheus+Grafana Y 扩展性好 容器,应用, ...
- Launch Instance---source for openstack
If you want to create an instance that uses ephemeral storage, meaning the instance data is lost whe ...
- Java中的Static修饰符
static(静态.修饰符):static修饰成员变量时:static修饰成员变量时,那么该成员变量的数据就是一个共享的数据. 静态成员变量的访问方式:方式一: 使用对象进行访问. 对象.属性名 方式 ...