-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpoj1106.cpp
More file actions
79 lines (61 loc) · 1.6 KB
/
poj1106.cpp
File metadata and controls
79 lines (61 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#include <cstdio>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;
int dcmp(double a) {
if(fabs(a) < eps) return 0;
return a>0?1:-1;
}
struct Point {
double x, y;
Point() {}
Point(int x, int y): x(x), y(y) {}
Point& operator = (Point P) {
x = P.x;
y = P.y;
return *this;
}
};
typedef Point Vec;
Vec operator - (Point A, Point B) {return Vec(A.x-B.x, A.y-B.y);};
double dot(Vec a, Vec b) { return a.x*b.x + a.y*b.y; }
double cross(Vec a, Vec b) { return a.x*b.y - a.y*b.x; }
vector<Point> allP;
Point Center;
bool inSemiCircle(Vec OA, Point B) {
Vec OB = B - Center;
double c = cross(OA, OB);
return c >= 0;
}
int countInside(int idx) {
Vec OA = allP[idx] - Center;
int count = 0;
for(int i = 0; i < allP.size(); ++i)
if(i != idx && inSemiCircle(OA, allP[i]))
count++;
return count + 1;
}
double dists(Point A, Point B) {
return (A.x-B.x)*(A.x-B.x) + (A.y-B.y)*(A.y-B.y);
}
int main() {
// freopen("input.txt", "r", stdin);
int npoints;
double radius;
while(scanf("%lf%lf%lf", &Center.x, &Center.y, &radius) != EOF && radius > 0) {
scanf("%d", &npoints);
allP.clear();
for(int i = 0; i <npoints; ++i) {
Point cur;
scanf("%lf%lf", &cur.x, &cur.y);
if(dists(Center, cur) <= radius*radius)
allP.push_back(cur);
}
int maxCount = 0;
for(int i = 0; i < allP.size(); ++i)
maxCount = max(maxCount, countInside(i));
printf("%d\n", maxCount);
}
return 0;
}