forked from daiwb/Algorithm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1041Transmitters.cpp
More file actions
60 lines (53 loc) · 1.31 KB
/
1041Transmitters.cpp
File metadata and controls
60 lines (53 loc) · 1.31 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
//ZJU 1041 Transmitters
//2003.09.13 BY adai
#include <iostream>
#include <cmath>
using namespace std;
int main(void){
int i,j;
double rx,ry,r,tx,ty,temp;
while(1){
cin>>rx>>ry>>r;
if(r<=0) break;
int num;
cin>>num;
int* x=new int[num];
int* y=new int[num];
int t=0;
for(i=0;i<num;i++){
cin>>x[t]>>y[t];
if(pow(rx-x[t],2)+pow(ry-y[t],2)<=pow(r,2)) t++;
}
int max=0;
int left,right;
for(i=0;i<t;i++){
if(x[i]==rx&&y[i]==ry){
if(max==0) max=1;
continue;
}
tx=x[i];
ty=y[i];
left=right=1;
j=i;
while(1){
j++;
if(j>=t) j=0;
if(j==i) break;
if(x[j]==rx&&y[j]==ry){
left++;
right++;
continue;
}
temp=(y[j]-ry)*(tx-rx)-(x[j]-rx)*(ty-ry);
if(temp>=0) left++;
if(temp<=0) right++;
}
if(left>max) max=left;
if(right>max) max=right;
}
delete []x;
delete []y;
cout<<max<<endl;
}
return 0;
}