首页 > 其他 > 详细

ZOJ 1049 I Think I Need a Houseboat

时间:2014-02-27 09:03:36      阅读:438      评论:0      收藏:0      [点我收藏+]

原题链接

题目大意:Fred想在Louisiana买一套房子,但是堤坝不牢固,每年都要被河水侵蚀50平方英里。题目给出他豪宅的坐标,要求他被迫移民搬迁的年份。

解法:也没什么好说的,先求出两点间的距离,即半径,然后算出面积,在除以每年塌方的面积,向上取整即可。

 

参考代码:

#include <stdio.h>
#include <math.h>
#define PI 3.14
int main(){
	int n=1,N,year;
	float X,Y,dist,area;
	scanf("%d",&N);
	while(n<=N){
		scanf("%f%f",&X,&Y);
		dist = X*X+Y*Y;
		dist = sqrt(dist);
		area = PI*dist*dist/2/50;
		year = ceil(area);
		printf("Property %d: This property will begin eroding in year %d.\n",n,year);
		n++;
	}
	printf("END OF OUTPUT.");
	return 0;
}

ZOJ 1049 I Think I Need a Houseboat,布布扣,bubuko.com

ZOJ 1049 I Think I Need a Houseboat

原文:http://www.cnblogs.com/naive/p/3568748.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!