Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class Durts {
- public static void main(String[] args) {
- Scanner input = new Scanner(System.in);
- double centerY = input.nextDouble();
- double centerX = input.nextDouble();
- double boardRadius = input.nextDouble();
- double shots = input.nextDouble();
- //--------------get board coordinates as two rectangles----------------//
- //-------rect one coordinates-------//
- double rectOneX1 = centerX + (boardRadius/2);
- double rectOneY1 = centerY - (boardRadius);
- double rectOneX2 = centerX - (boardRadius/2);
- double rectOneY2 = centerY + (boardRadius);
- //-------rectTwo coordinates----------//
- double rectTwoX1 = centerX + (boardRadius);
- double rectTwoY1 = centerY - (boardRadius/2);
- double rectTwoX2 = centerX - (boardRadius);
- double rectTwoY2 = centerY + (boardRadius/2);
- //System.out.println("recOne x1 " + rectOneX1 + " " + "y1 " + rectOneY1 + " " + "x2 " + rectOneX2 + " " + "y2 " + rectOneY2);
- //System.out.println("rexTwo x1 " + rectTwoX1 + " " + "y1 " + rectTwoY1 + " " + "x2 " + rectTwoX2 + " " + "y2 " + rectTwoY2);
- for (int i = 0; i <shots; i++) {
- int shotY = input.nextInt();
- int shotX = input.nextInt();
- if(shotX <= rectOneX1 && shotY <= rectOneY2 && shotY >= rectOneY1 && shotX >= rectOneX2){
- System.out.println("yes");
- }
- else if(shotX <= rectTwoX1 && shotY <= rectTwoY2 && shotY >= rectTwoY1 && shotX >= rectTwoX2){
- System.out.println("yes");
- }
- else{
- System.out.println("no");
- }
- }
- input.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement