Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static class Solver {
- public void solve(InputReader in, PrintWriter out) {
- int t = in.nextInt();
- for (int i = 0; i < t; ++i) {
- double p = in.nextDouble();
- double x = in.nextDouble() - 50;
- double y = in.nextDouble() - 50;
- double angle = p * 360 / 100;
- int q = quadrant(x, y);
- if (Math.hypot(x, y) > 50) {
- out.printf("Case #%d: white\n", i + 1);
- continue;
- }
- if ((x == 0 && y == 0 && angle > 0) || (q == 90 && angle == 90) || (q == 180 && angle == 180) || (q == 270 && angle == 270) || (q == 360 && angle == 360)) {
- out.printf("Case #%d: black\n", i + 1);
- continue;
- }
- double tangent = Math.abs(x / y);
- double angle1 = Math.atan(tangent) * 180 / Math.PI;
- if (q == 2) {
- angle1 += 90;
- } else if (q == 3) {
- angle1 += 180;
- } else if (q == 4) {
- angle1 += 270;
- }
- out.printf("Case #%d: %s\n", i + 1, angle1 <= angle ? "black" : "white");
- }
- }
- }
- static int quadrant(double x, double y) {
- if (x > 0 ) {
- if (y > 0) {
- return 1;
- } else if (y < 0) {
- return 2;
- }
- } else if (x < 0) {
- if (y > 0) {
- return 4;
- } else if (y < 0) {
- return 3;
- }
- }
- if (x > 0 && y == 0) {
- return 90;
- } else if (x == 0 && y < 0) {
- return 180;
- } else if (x < 0 && y == 0) {
- return 270;
- }
- return 360;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement