首页 > 代码库 > 【POJ1005】I Think I Need a Houseboat

【POJ1005】I Think I Need a Houseboat

说是计算几何,其实是一道水题。直接算半圆面积即可。

 

 1 #include <iostream> 2 #include <cstdlib> 3 #include <cstdio> 4 #include <cstring> 5 #include <cctype> 6 #include <numeric> 7 #include <cmath> 8 #include <algorithm> 9 10 #define PI acos(-1)11 12 using namespace std;13 int main () {14     //cout << PI << endl;15     ios :: sync_with_stdio(false);16     int T; cin >> T;17     int cnt = 0;18     while (T --) {19         double x, y;20         cin >> x >> y;21         double S = 0.5 * (x * x + y * y) * PI / 50.0;22         //cout << S << endl;23         int ans = ceil(S);24         printf ("Property %d: This property will begin eroding in year %d.\n", ++ cnt, ans);25         if (T == 0) {26             printf ("END OF OUTPUT.\n");27         }28     }29     return 0;30 }

 

【POJ1005】I Think I Need a Houseboat