poj 1005 I Think I Need a Houseboat

来源:互联网 发布:淘宝店铺直播招人 编辑:程序博客网 时间:2024/06/11 15:38

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;}