406146: GYM102279 D Dahlia The Champion

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

D. Dahlia The Championtime limit per test1.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output

Lowie is creating a new champion in the critically acclaimed game LoL (Land of Literacy). Named it Dahlia, he planned that the champion will have 4 different abilities. One of them is Pull 'em Over.

Long story short: Assuming that the map is a Cartesian plane (an $$$O-xy$$$ plane), Dahlia and the targets are small enough to be considered as points. When Pull 'em Over is activated, Dahlia throws her stretchy arms at a direction of her choice, and if there is any target in the direction with the distance not more than $$$R$$$ from her, Dahlia pull the first target she reaches towards her immediately.

Supposed that Dahlia is standing in position $$$(x_0, y_0)$$$. There are $$$N$$$ different target in the map. Without any movements from her and all of the targets, count the number of targets she can choose to Pull 'em Over.

Input

The first line contains four integers: $$$x_0$$$, $$$y_0$$$, $$$R$$$, $$$N$$$. ($$$|x_0|, |y_0| \le 10^9$$$, $$$1 \le R \le 10^9$$$, $$$1 \le N \le 5*10^5$$$) - the coordinates of Dahlia, the radius she can cover, and the number of targets.

The $$$i$$$-th line of the next $$$N$$$ lines contain two integers: $$$x_i$$$ and $$$y_i$$$ - coordinates of the $$$i$$$-th target.

It is guaranteed that there are no two targets standing on a same position on the map, and there are no targets stand on the same position as Dahlia.

Output

Output a single integer denotes your answer to the test - number of targets she can choose to Pull 'em Over.

ExamplesInput
0 0 10 4
1 2
4 1
-1 -2
3 -4
Output
4
Input
1 2 5 4
-2 -2
6 2
10 1
-2 1
Output
3

加入题单

算法标签: