Advertisement
Guest User

Untitled

a guest
Jan 10th, 2017
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 KB | None | 0 0
  1. static class Solver {
  2. public void solve(InputReader in, PrintWriter out) {
  3. int t = in.nextInt();
  4. for (int i = 0; i < t; ++i) {
  5. double p = in.nextDouble();
  6. double x = in.nextDouble() - 50;
  7. double y = in.nextDouble() - 50;
  8. double angle = p * 360 / 100;
  9. int q = quadrant(x, y);
  10. if (Math.hypot(x, y) > 50) {
  11. out.printf("Case #%d: white\n", i + 1);
  12. continue;
  13. }
  14. if ((x == 0 && y == 0 && angle > 0) || (q == 90 && angle == 90) || (q == 180 && angle == 180) || (q == 270 && angle == 270) || (q == 360 && angle == 360)) {
  15. out.printf("Case #%d: black\n", i + 1);
  16. continue;
  17. }
  18. double tangent = Math.abs(x / y);
  19. double angle1 = Math.atan(tangent) * 180 / Math.PI;
  20. if (q == 2) {
  21. angle1 += 90;
  22. } else if (q == 3) {
  23. angle1 += 180;
  24. } else if (q == 4) {
  25. angle1 += 270;
  26. }
  27. out.printf("Case #%d: %s\n", i + 1, angle1 <= angle ? "black" : "white");
  28. }
  29. }
  30. }
  31. static int quadrant(double x, double y) {
  32. if (x > 0 ) {
  33. if (y > 0) {
  34. return 1;
  35. } else if (y < 0) {
  36. return 2;
  37. }
  38. } else if (x < 0) {
  39. if (y > 0) {
  40. return 4;
  41. } else if (y < 0) {
  42. return 3;
  43. }
  44. }
  45. if (x > 0 && y == 0) {
  46. return 90;
  47. } else if (x == 0 && y < 0) {
  48. return 180;
  49. } else if (x < 0 && y == 0) {
  50. return 270;
  51. }
  52. return 360;
  53. }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement