您的位置:首页 > 其它

poj 1005 I Think I Need a Houseboat【math】

2017-09-27 22:29 537 查看
http://poj.org/problem?id=1005

分析:读懂题意最重要!半圆代表的意思为被腐蚀的面积,即随之时间推移,半圆面积是在不断扩大的。起初以为是陆地即为半圆,随着时间不断缩减。。。。Fred has learned that the land that is being lost forms a semicircle.

思路即为根据(x,y)确定与中心的距离,计算此时的半圆面积是几个50. 注意对于PI的处理 const double PI = 3.14159

#include"stdio.h"
#include"math.h"
const double PI = 3.14159;
int main()
{
int i = 1,n,year;
double x,y,d;
scanf("%d",&n);
while(i<=n)
{
year = 1;//注意从1开始
scanf("%lf%lf",&x,&y);
d = pow(x,2)+pow(y,2);
year = year + PI*d/2/50;
printf("Property %d: This property will begin eroding in year %d.\n",i,year);
i++;
}
printf("END OF OUTPUT.\n");
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: