POJ1005
题目很良心,没有什么坑爹的特殊情况,主要注意是每年增加50面积,那么可以算出每年的半径,与给出的点比较一下就好了,没有枚举答案,用的是二分
#include<cmath>
#include<cstdio>
using namespace std;
const double pi=3.14159,eps=0.001;
int N;
int main(){
scanf("%d", &N);
for (int i=1; i<=N; ++i){
double x,y,dis;scanf("%lf%lf", &x, &y);
dis=sqrt(x*x+y*y);
int L=1,R=1000;
while (L<=R){
int mid=(L+R)/2;
double midr=sqrt(100.0*mid/pi);
if (midr-dis>=eps) R=mid-1; else L=mid+1;
}
printf("Property %d: This property will begin eroding in year %d.\n", i, L);
}
printf("END OF OUTPUT.\n");
return 0;
}

浙公网安备 33010602011771号