首页 > 其他 > 详细

POJ-1005

时间:2015-07-11 06:42:39      阅读:254      评论:0      收藏:0      [点我收藏+]
#include<iostream>
#include<cmath>
//#include<algorithm>
using namespace std;

#define PI 3.1415926

/*
return: years
*/
int recursionFunc(float rCurrent, float xYMin){
	float r;

	if(rCurrent==0){
		r=sqrt(100.0/PI);
	}else{
		r=sqrt(100.0/PI+pow(rCurrent,2));
	}
	
	if(r>xYMin){
		return 1;
	}else{
		return 1+recursionFunc(r, xYMin);
	}
}

int main(int argc, char *argv[]){
	int n;
	float x,y;
	float r;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>x>>y;
		r=sqrt(pow(x,2)+pow(y,2));

		cout<<"Property "<<i+1<<": This property will begin eroding in year "<<recursionFunc(0,r)<<"."<<endl;
	}

	cout<<"END OF OUTPUT."<<endl;

	return 0;
}



















版权声明:本文为博主原创文章,未经博主允许不得转载。

POJ-1005

原文:http://blog.csdn.net/eddy_liu/article/details/46837331

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