poj 1005
1.题目链接:poj 1005
2.题目解析:
- 题目告诉我们有一块半圆土地,以每年50个单位消失,问几年后开始完全消失
- 题目给出坐标,以次我们可以计算出半径,进而计算出这块土地的面积
- 根据题意,可得到公式:年数 = ½ πr² / 50 + 1(年数要取整,故加1)
3.代码示例
#include <stdio.h>
#define PI 3.141592654
int main()
{
int n,m,num;
double x, y;
scanf("%d", &n);
m = 1;
while (n--)
{
scanf("%lf", &x);
scanf("%lf", &y);
num = 0.5 * PI * (x*x + y * y) / 50 + 1;
printf("Property %d: This property will begin eroding in year %d.\n", m++,num);
}
printf("END OF OUTPUT.");
}