1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| #include <iostream> #include <algorithm> #include <cmath> using namespace std; const double PI = acos(-1); const int N = 101; int n; int r[N]; int main() { scanf("%d", &n); for (int i = 0; i < n; ++i) scanf("%d", &r[i]); sort(r, r + n, greater<int>()); double ans = 0; for (int i = 0; i < n; i += 2) ans += PI * (r[i] * r[i] - r[i + 1] * r[i + 1]); printf("%lf\n", ans); return 0; }
|