Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class _2_Durts {
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- Scanner scan = new Scanner(System.in);
- int centerX = scan.nextInt();
- int centerY = scan.nextInt();
- int size = scan.nextInt();
- int count = scan.nextInt();
- int pointX, pointY;
- for (int i = 0; i < count; i++) {
- pointX = scan.nextInt();
- pointY = scan.nextInt();
- int minLeft = centerX - size;
- int maxRight = centerX + size;
- int bottom = centerY - (size / 2);
- int top = centerY + (size / 2);
- boolean pointIsInside = pointX >= minLeft && pointX <= maxRight
- && pointY >= bottom && pointY <= top;
- if (!pointIsInside) {
- minLeft = centerX - (size / 2);
- maxRight = centerX + (size / 2);
- bottom = centerY - size;
- top = centerY + size;
- pointIsInside = pointX >= minLeft && pointX <= maxRight
- && pointY >= bottom && pointY <= top;
- }
- System.out.println(pointIsInside ? "yes" : "no");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement