-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy path1106.cc
70 lines (63 loc) · 1.73 KB
/
1106.cc
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
//Name: Transmitters
//Level: 2
//Category: しゃくとり法
//Note:
/*
* 必ず1点は半径上に乗っているはずなので、一箇所調べたら次の角度は
* 点と半径がぶつかるところになる。
*/
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
using namespace std;
typedef complex<double> Point;
//const double M_PI = 3.1415926;
bool operator< (const Point &p1, const Point &p2) {
return arg(p1) < arg(p2);
}
int main() {
while(true) {
double x, y, radius;
int N;
cin >> x >> y >> radius;
if(radius < 0) break;
cin >> N;
Point center = Point(x, y);
vector<double> args;
for(int i = 0; i < N; ++i) {
double px, py;
cin >> px >> py;
Point p = Point(px, py)-center;
if(abs(p) > radius) continue;
args.push_back(arg(p));
//cout << points[i] << " " << arg(points[i]) << endl;
}
sort(args.begin(), args.end());
/*
for(int i = 0; i < args.size(); ++i) {
cout << args[i] << endl;
}
*/
int cnt = 0;
int best = 0;
int left = 0, right = 0;
while(left < args.size()) {
int orgright = right;
while(args[right]-args[left] <= M_PI) {
++cnt;
right = (right+1)%args.size();
if(right == orgright) break;
}
if(cnt > best) best = cnt;
//cout << left << ":" << cnt << endl;
args[left] += M_PI*2;
//cout << left << ":" << cnt << endl;
++left;
--cnt;
}
cout << best << endl;
}
return 0;
}