Stuffbyliang

Untitled

Feb 11th, 2019
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.15 KB | None | 0 0
  1. import java.util.*;
  2. public class Main {
  3.     public static void main(String[] args) {
  4.         Scanner s = new Scanner(System.in);
  5.         byte a = s.nextByte();
  6.         for(byte i = 0; i < a; i++) {
  7.             int n = s.nextInt();
  8.             int x = s.nextInt();
  9.             int y = s.nextInt();
  10.             if(find(n, x, y))
  11.                 System.out.println("crystal");
  12.             else
  13.                 System.out.println("empty");
  14.         }
  15.  
  16.     }
  17.     static boolean find(int n, int x, int y) {
  18.         int a = (int) Math.pow(5, n - 1); //n x n grid
  19.         //if x is less than 1/5 of iterants
  20.  
  21.         int X = x / a;
  22.         int Y = y / a;
  23.         if(((X == 1 || X == 3) && Y == 0) || (X == 2 && (Y == 0 || Y == 1))) {
  24.             return true;
  25.         }
  26.         else if(n == 1)
  27.             return false;
  28.         else if(X == 1 && Y == 1)
  29.             return find(n - 1, x - a, y - a);
  30.         else if(X == 3 && Y == 1) {
  31.             return find(n - 1, x - (3 * a), y - a);
  32.         }
  33.         else if(X == 2 && Y == 2) {
  34.             return find(n - 1, x - (2 * a), y - (2 * a));
  35.         }
  36.         else
  37.             return false;
  38.  
  39.     }
  40. }
Add Comment
Please, Sign In to add comment