标签:
1 #include <iostream> 2 #include <cstdio> 3 #include <algorithm> 4 using namespace std; 5 6 int main() 7 { 8 int n, i, j, k, cases; 9 double area, x[105], y[105], r[105], dx[105*2], dy[105*2]; 10 cases = 0; 11 while(cin>>n && n) 12 { 13 for(i=0; i<n; i++) 14 { 15 cin >> x[i] >> y[i] >> r[i]; 16 dx[i*2] = x[i] - r[i], dx[i*2+1] = x[i] + r[i]; 17 dy[i*2] = y[i] - r[i], dy[i*2+1] = y[i] + r[i]; 18 } 19 sort(dx, dx+2*n); 20 sort(dy, dy+2*n); 21 area = 0.0; 22 for(i = 1; i < 2*n; i++) 23 for(j = 1; j < 2*n; j++) 24 for(k = 0; k < n; k++) 25 { 26 if(dx[i-1]>=x[k]-r[k] && dx[i]<=x[k]+r[k]) 27 if(dy[j-1]>=y[k]-r[k] && dy[j]<=y[k]+r[k]) 28 { 29 area += (dx[i] - dx[i-1]) * (dy[j] - dy[j-1]); 30 break; 31 } 32 } 33 printf("%d %.2lf\n", ++cases, area); 34 } 35 return 0; 36 }
uva 688 - Mobile Phone Coverage
标签:
原文地址:http://www.cnblogs.com/aze-003/p/5094803.html