Advertisement
Malinovsky239

Untitled

Jan 15th, 2012
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.83 KB | None | 0 0
  1. #include <cstdio>
  2. #include <iostream>
  3. #include <cmath>
  4.  
  5. #define N int(1e5 + 5)
  6.  
  7. using namespace std;
  8.  
  9. typedef long long LL;
  10.  
  11. int n, x[N], y[N], r[N];
  12. bool in[N];
  13.  
  14. LL sqr(LL a) {
  15.     return a * a;
  16. }
  17.  
  18. int main() {
  19.     freopen("circles.in", "r", stdin);
  20.     freopen("circles.out", "w", stdout);
  21.  
  22.     scanf("%d ", &n);                                          
  23.  
  24.     for (int i = 0; i < n; i++)
  25.         scanf("%d %d %d ", x + i, y + i, r + i);
  26.  
  27.     if (n <= 5000) {
  28.         for (int i = 0; i < n; i++)
  29.             for (int j = 0; j < n; j++) {
  30.                 if (i == j) continue;
  31.  
  32.                 if (sqr(r[i] - r[j]) >= sqr(x[i] - x[j]) + sqr(y[i] - y[j]) && r[i] <= r[j])
  33.                     in[i]++;
  34.             }
  35.     }
  36.    
  37.     long double res = 0;
  38.     for (int i = 0; i < n; i++)
  39.         if (!in[i])
  40.             res += M_PI * sqr(r[i]);
  41.  
  42.     cout.precision(9);
  43.     cout << fixed << res << endl;
  44.  
  45.     return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement