Decription
有一个圆心在原点,位于X轴上方的小岛,小岛从圆心处每年都会被腐蚀50平方英里,问多少年后腐蚀到(X,Y)处
Input
n组输入,每组输入包括两个浮点数X,Y
Output
腐蚀到(X,Y)处年数,以“END OF OUTPUT.”结束输出
Sample Input
2
1.0 1.0
25.0 0.0
Sample Output
Property 1: This property will begin eroding in year 1.
Property 2: This property will begin eroding in year 20.
END OF OUTPUT.
Solution
求出以询问点所处圆环为边缘的半圆面积处于每年腐蚀面积再加一即可,水题一道……
Code
#include<stdio.h>
#include<math.h>
int main()
{
float x,y,s,m;
int n,i,j;
scanf("%d",&n);
for(i=1;i<=n;i++)
{
s=0;
scanf("%f%f",&x,&y);
s=(x*x+y*y)*(acos(-1))/2;
m=s/50+0.5;//加0.5后以%d输出会四舍五入可以将浮点数变成不小于其的整数
printf("Property %d: This property will begin eroding in year %.0f.\n",i,m);
}
printf("END OF OUTPUT.\n");
}