题意就是,有一块半圆形区域,从0,0点开始向四周扩展,每年扩展50.0面积(单位统一不用考虑)。

计算给定点在第几年结束之前被圆形区域覆盖。

 

我的思路:

1、计算以给定点到原点长度的半径做半圆的面积。

2、除以50.0,所得结果加1,就是所求

PI取3.14159265

 

#include<iostream>
#include<string>
using namespace std;

int main()
{
    double x, y;
    int n;
    const double PI = 3.14159265;
    const string s1="Property ",s2 = ": This property will begin eroding in year ",s3="END OF OUTPUT.";
    cin >> n;
    for (int k = 1; k <= n; k++)
    {
        cin >> x >> y;
        double area = (x*x + y*y)/2*PI;
        int ans = int(area/50.0)+1;
        cout << s1 << k << s2 << ans << "." << endl;
    }
    cout << s3 << endl;
    return 0;
}

 

posted on 2014-11-10 19:42  xlert  阅读(167)  评论(0编辑  收藏  举报