Advertisement
Guest User

Untitled

a guest
Nov 24th, 2015
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 KB | None | 0 0
  1. import java.util.*;
  2. import java.io.*;
  3. import java.math.*;
  4.  
  5. /**
  6. * Auto-generated code below aims at helping you parse
  7. * the standard input according to the problem statement.
  8. * ---
  9. * Hint: You can use the debug stream to print initialTX and initialTY, if Thor seems not follow your orders.
  10. **/
  11. class Player
  12. {
  13.  
  14. public static void main(String args[])
  15. {
  16. Scanner in = new Scanner(System.in);
  17. int lightX = in.nextInt(); // the X position of the light of power
  18. int lightY = in.nextInt(); // the Y position of the light of power
  19. int initialTX = in.nextInt(); // Thor's starting X position
  20. int initialTY = in.nextInt(); // Thor's starting Y position
  21. String dir = "";
  22.  
  23. // game loop
  24. while (true)
  25. {
  26. int remainingTurns = in.nextInt(); // The remaining amount of turns Thor can move. Do not remove this line.
  27. int TX = initialTX;
  28. int TY = initialTY;
  29. int LX = lightX;
  30. int LY = lightY;
  31.  
  32.  
  33. if(TX < LX && TY < LY)
  34. dir = "SE";
  35. else if(TX < LX && TY > LY)
  36. dir = "NE";
  37. else if(TX < LX && TY == LY)
  38. dir = "E";
  39. else if(TX > LX && TY < LY)
  40. dir = "SW";
  41. else if(TX > LX && TY > LY)
  42. dir = "NW";
  43. else if(TX > LX && TY == LY)
  44. dir = "W";
  45. else if(TX == LX && TY > LY)
  46. dir = "N";
  47. else if(TX == LX && TY < LY)
  48. dir = "S";
  49.  
  50. System.out.println(dir);
  51. }
  52.  
  53. }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement