Point on the plane (square)

Description


Given a square and several points, find the number of points in the square (including points on the sides of the square). Here the four sides of the square are parallel to the (x) and (y) coordinate axes.

Format


Input

The four integers (x), (y), (l), and (n) in the first line are the (X) and (Y) coordinates of the lower left corner of the square, side length and the number of points ((-10000≤x,y≤10000),(l≤10000),(n≤10000));
The next (n) lines have two numbers (x_i) and (y_i), which represent the coordinates of each point, (-10000≤x_i, y_i≤10000).

Output

An integer representing the number of points contained in the square.

Sample


Input

0 0 5 5
1 2
3 4
6 7
5 3
2 8

Output

3

Sample Code


#include <cstdio>
inline bool btw(int a, int b, int c){
	return a>=b && a<=c;
}
int main(){
    freopen("square.in", "r", stdin);
    freopen("square.out", "w", stdout);
    int x, y, l, n;
    scanf("%d %d %d %d", &x, &y, &l, &n);
    int ans=0;
    while (n--){
		int u, v;
		scanf("%d %d", &u, &v);
		ans+= (btw(u, x, x+l) && btw(v, y, y+l));
	}
	printf("%d
", ans);
    return 0;
}
原文地址:https://www.cnblogs.com/jiupinzhimaguan/p/13806404.html