Advertisement
YankoZlatanov

Untitled

Feb 10th, 2015
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.54 KB | None | 0 0
  1. import java.util.*;
  2.  
  3. public class Durts {
  4.     public static void main(String[] args) {
  5.  
  6.         Scanner input = new Scanner(System.in);
  7.         double centerY = input.nextDouble();
  8.         double centerX = input.nextDouble();
  9.         double boardRadius = input.nextDouble();
  10.         double shots = input.nextDouble();
  11.         //--------------get board coordinates as two rectangles----------------//
  12.         //-------rect one coordinates-------//
  13.         double rectOneX1 = centerX + (boardRadius/2);
  14.         double rectOneY1 = centerY - (boardRadius);
  15.         double rectOneX2 = centerX  - (boardRadius/2);
  16.         double rectOneY2 = centerY + (boardRadius);
  17.         //-------rectTwo coordinates----------//
  18.         double rectTwoX1 = centerX  + (boardRadius);
  19.         double rectTwoY1 = centerY - (boardRadius/2);
  20.         double rectTwoX2 = centerX  - (boardRadius);
  21.         double rectTwoY2 = centerY + (boardRadius/2);
  22.        
  23.         //System.out.println("recOne x1 " + rectOneX1 + " " + "y1 " + rectOneY1 + " " + "x2 " + rectOneX2 + " " + "y2 " + rectOneY2);
  24.        
  25.         //System.out.println("rexTwo x1 " + rectTwoX1 + " " + "y1 " + rectTwoY1 + " " + "x2 " + rectTwoX2 + " " + "y2 " + rectTwoY2);
  26.        
  27.         for (int i = 0; i <shots; i++) {
  28.            
  29.             int shotY = input.nextInt();
  30.             int shotX = input.nextInt();
  31.            
  32.             if(shotX <= rectOneX1 && shotY <= rectOneY2 && shotY >= rectOneY1 && shotX >= rectOneX2){
  33.                 System.out.println("yes");
  34.             }
  35.             else if(shotX <= rectTwoX1 && shotY <= rectTwoY2 && shotY >= rectTwoY1 && shotX >= rectTwoX2){
  36.                 System.out.println("yes");
  37.             }
  38.             else{
  39.                 System.out.println("no");
  40.             }
  41.            
  42.         }
  43.         input.close();
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement