I Think I Need a Houseboat 1005 PKU
2010-06-06 14:55
381 查看
description:
某个地方被Mississippi河腐蚀每年都会有50square miles,而且总共腐蚀是个半圆,求给定一个点什么时候会被腐蚀
solution:
求该点到(0,0)的长度r,求以r为半径半圆的面积area,除以50即可得到答案
1. 一个难点是浮点型精度的处理,但是好像多想了,题目给出HINT:No property will appear exactly on the semicircle boundary: it will either be inside or outside.
某个地方被Mississippi河腐蚀每年都会有50square miles,而且总共腐蚀是个半圆,求给定一个点什么时候会被腐蚀
solution:
求该点到(0,0)的长度r,求以r为半径半圆的面积area,除以50即可得到答案
1. 一个难点是浮点型精度的处理,但是好像多想了,题目给出HINT:No property will appear exactly on the semicircle boundary: it will either be inside or outside.
#include <stdio.h> #define PI 3.1415926535 #define EPS 1e-6 int main() { int cases=0,i=0; double year=0; double area=0,x=0,y=0; scanf ("%d",&cases); for (i=1; i<=cases; i++) { scanf ("%lf %lf",&x,&y); area = (x*x+y*y)*PI/2; year = area / 50; printf ("Property %d: This property will begin eroding in year %d.\n", i,(int)(year-EPS)+1); } printf("END OF OUTPUT.\n"); return 0; }
相关文章推荐
- pku 1005 I Think I Need a Houseboat
- PKU 1005 I Think I Need a Houseboat
- PKU_1005_I Think I Need a Houseboat
- I Think I Need a Houseboat(PKU1005)
- POJ 1005I Think I Need a Houseboat解题报告——【PKU ACM】
- POJ1005-I Think I Need a Houseboat
- poj1005 I Think I Need a Houseboat
- poj 1005 I Think I Need a Houseboat-----计算几何
- 1005:I Think I Need a Houseboat
- POJ 1005-I Think I Need a Houseboat
- poj 1005 I Think I Need a Houseboat【math】
- POJ 1005 I Think I Need a Houseboat (水题)
- POJ-1005 I Think I Need a Houseboat-房屋淹没
- poj1005 I Think I Need a Houseboat 水题
- POJ-1005 I Think I Need a Houseboat
- 百练 1005 I Think I Need a Houseboat
- Poj_1005_I Think I Need A HouseBoat
- 1005:I Think I Need a Houseboat
- 【POJ】1005 I Think I Need a Houseboat
- I Think I Need a Houseboat - POJ 1005 水题