Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class Main {
- public static void main(String[] args) {
- Scanner s = new Scanner(System.in);
- byte a = s.nextByte();
- for(byte i = 0; i < a; i++) {
- int n = s.nextInt();
- int x = s.nextInt();
- int y = s.nextInt();
- if(find(n, x, y))
- System.out.println("crystal");
- else
- System.out.println("empty");
- }
- }
- static boolean find(int n, int x, int y) {
- int a = (int) Math.pow(5, n - 1); //n x n grid
- //if x is less than 1/5 of iterants
- int X = x / a;
- int Y = y / a;
- if(((X == 1 || X == 3) && Y == 0) || (X == 2 && (Y == 0 || Y == 1))) {
- return true;
- }
- else if(n == 1)
- return false;
- else if(X == 1 && Y == 1)
- return find(n - 1, x - a, y - a);
- else if(X == 3 && Y == 1) {
- return find(n - 1, x - (3 * a), y - a);
- }
- else if(X == 2 && Y == 2) {
- return find(n - 1, x - (2 * a), y - (2 * a));
- }
- else
- return false;
- }
- }
Add Comment
Please, Sign In to add comment