14 vector
<pair
<D
,D
> > point
;
16 double hypot(double x
, double y
){
19 double cruz(pair
<D
,D
> p1
, pair
<D
,D
> p2
, pair
<D
,D
> p3
){
20 double x1
, x2
, y1
, y2
;
21 x1
= p2
.first
- p1
.first
, x2
= p3
.first
- p1
.first
;
22 y1
= p2
.second
- p1
.second
, y2
= p3
.second
- p1
.second
;
23 return acos( (x1
*x2
+y1
*y2
)/(hypot(x1
,y1
)*hypot(x2
,y2
)));
25 double dist(pair
<D
,D
> p1
, pair
<D
,D
> p2
){
27 dx
= p2
.first
-p1
.first
, dy
= p2
.second
- p1
.second
;
33 bool menor(pair
<pair
<D
,D
>,int> p1
, pair
<pair
<D
,D
>,int> p2
){
34 double c
= cruz(P
, p1
.first
,p2
.first
);
35 if( fabs(c
) < EPS
) return false;
38 void PROVE(vector
<pair
<D
,D
> > &vec
, pair
<D
,D
> p
){
39 vector
<pair
<double,int> > interval
;
42 for(k
=0;k
<vec
.size();k
++){
44 xmed
= (p
.first
+vec
[k
].first
)/2., ymed
= (p
.second
+vec
[k
].second
)/2.;
45 // calculamos la alturita del triángulo...
46 D d
= dist(make_pair(xmed
,ymed
),p
);
47 D altura
= sqrt(max(R
*R
-d
*d
,0.));
49 xch
= vec
[k
].second
-ymed
;
50 ych
= xmed
-vec
[k
].first
;
52 xch
*= altura
, ych
*= altura
;
55 p1
.first
= xmed
+xch
; //min(p.first,xmed + xch);
56 p2
.first
= xmed
-xch
; //min(p.first,xmed - xch);
57 p1
.second
= ymed
+ ych
;
58 p2
.second
= ymed
- ych
;
60 c1
= cruz(p
,p1
,make_pair(p
.X
,10000000000000.));
61 c2
= cruz(p
,p2
,make_pair(p
.X
,10000000000000.));
63 if( p1
.first
> p
.first
) c1
= 2.*V
-c1
;
64 if( p2
.first
> p
.first
) c2
= 2.*V
-c2
;
65 if( p1
.first
> p
.first
&& p2
.first
< p
.first
){
66 if( vec
[k
].second
> p
.second
) cant
++;
69 interval
.push_back(make_pair(c1
,-1));
70 interval
.push_back(make_pair(c2
,1));
72 sort(interval
.begin(), interval
.end());
74 for(i
=(int)interval
.size()-1;i
>=0;i
--){
75 res
= max ( res
, abs(c
) );
76 c
+= interval
[i
].second
;
82 scanf("%i %lf", &N
, &R
);
85 for(i
=0;i
<N
;i
++){D x
, y
; scanf("%lf %lf", &x
, &y
); point
.push_back(make_pair(x
,y
));}
87 sort(point
.begin(), point
.end());
92 for(i
=0;i
<point
.size();i
++){
93 vector
<pair
<D
,D
> > AUX
;
94 for(j
=0;j
<point
.size();j
++){
95 if( j
== i
) continue;
96 if( dist(point
[i
], point
[j
]) > 2.* R
) continue;
97 AUX
.push_back(point
[j
]);
101 printf("It is possible to cover %i points.\n", res
+1);