分析:告诉房子的坐标,每年以(0,0)为圆心的一个半圆面积会增加50,问多少年后这个房子的位置会在那个半圆内。注意pi必须取3.1415926才能过。
#include<iostream>
#include<cmath>
using namespace std;
#define PI 3.1415926 //3.141592654就WA
int main()
{
int T,t=0,year;
double x,y,d,s;
cin>>T;
while(T--)
{
cin>>x>>y;
d=x*x+y*y; //半径的平方
s=0.5*PI*d; //半圆的面积
year=ceil(s/50.0); //向上取整
cout<<"Property "<<++t<<": This property will begin eroding in year "<<year<<".\n";
if(T==0)
cout<<"END OF OUTPUT."<<endl;
}
return 0;
}
HDU ACM 1065 I Think I Need a Houseboat
原文地址:http://blog.csdn.net/a809146548/article/details/46376303