标签:
Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 1827 Accepted Submission(s): 725
1 # include <bits/stdc++.h> 2 using namespace std; 3 const double eps = 1e-6; 4 5 struct Point 6 { 7 double x; 8 double y; 9 }p[305]; 10 11 double dis2(Point a, Point b) 12 { 13 return (b.y - a.y) * (b.y - a.y) + (b.x - a.x) * (b.x - a.x); 14 } 15 16 Point center(Point a, Point b) 17 { 18 Point aa, bb, mid; 19 aa.x = b.x - a.x; 20 aa.y = b.y - a.y; 21 mid.x = (a.x + b.x) / 2; 22 mid.y = (a.y + b.y) / 2; 23 double c = sqrt(1.0 - dis2(a, mid)); 24 if(fabs(aa.y) < eps) 25 { 26 bb.x = mid.x; 27 bb.y = mid.y + c; 28 } 29 else 30 { 31 double ang = atan(-aa.x / aa.y); 32 bb.x = mid.x + c * cos(ang); 33 bb.y = mid.y + c * sin(ang); 34 } 35 return bb; 36 } 37 38 int main() 39 { 40 int T; 41 scanf("%d", &T); 42 while(T--) 43 { 44 int n; 45 scanf("%d", &n); 46 for(int i = 0; i < n; i++) 47 { 48 scanf("%lf%lf", &p[i].x, &p[i].y); 49 } 50 Point cen; 51 int ans = 1, tep; 52 for(int i = 0; i < n; i++) 53 { 54 for(int j = i + 1; j < n; j++) 55 { 56 if(dis2(p[i], p[j]) > 4) 57 continue; 58 cen = center(p[i], p[j]); 59 tep = 0; 60 for(int k = 0; k < n; k++) 61 { 62 if(dis2(p[k], cen) <= 1 + eps) 63 tep++; 64 } 65 if(ans < tep) 66 ans = tep; 67 } 68 } 69 printf("%d\n", ans); 70 } 71 72 73 return 0; 74 }
标签:
原文地址:http://www.cnblogs.com/lyf-acm/p/5827269.html