# BugLife#1-D

Jan 18th, 2021 (edited)
50
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. import java.util.*;
2. import java.io.*;
3. import java.math.*;
4.
5. public class Main
6. {
7.     /*
8.         Let length = a, breadth = b
9.         So, X + Y = ab + 2a + 2b
10.         which can be written as,
11.             X + Y = 2a + ab + 2b + 4 - 4
12.         =>  X + Y = a(2 + b) + 2(b + 2) - 4
13.         =>  X + Y = (a + 2)(b + 2)
14.         =>  X + Y + 4 = (a + 2)(b + 2)
15.         So, we need two factorials of (X + Y + 4) which are > 2.
16.     */
17.
18.     //static long total = 0l;
19.
20.     public static void process(int test_number)throws IOException
21.     {
22.         long n = nl();
23.         //total += n;
24.         n += 4l;
25.         long lt = (long) Math.sqrt(n);
26.
27.         boolean flag = false;
28.         for(long i = 3; i <= lt; i++){
29.             if(n % i == 0){
30.                 //trace(i);
31.                 flag = true;
32.                 break;
33.             }
34.         }
35.
36.         pn(flag ? "YES" : "NO");
37.     }
38.
39.     static final long mod = (long)1e9+7l;
40.     static boolean DEBUG = true;
42.     static PrintWriter out;
43.     public static void main(String[]args)throws IOException
44.     {
45.         out = new PrintWriter(System.out);
47.
48.         long s = System.currentTimeMillis();
49.         int t = 1;
50.         t = ni();
51.         for(int i = 1; i <= t; i++)
52.             process(i);
53.         //out.printf("%.15f\n", (total - 1e16));
54.         out.flush();
55.         System.err.println(System.currentTimeMillis()-s+"ms");
56.     }
57.
58.     static void trace(Object... o){ if(!DEBUG) return; System.err.println(Arrays.deepToString(o)); };
59.     static void pn(Object o){ out.println(o); }
60.     static void p(Object o){ out.print(o); }
61.     static int ni()throws IOException{ return Integer.parseInt(sc.next()); }
62.     static long nl()throws IOException{ return Long.parseLong(sc.next()); }
63.     static double nd()throws IOException{ return Double.parseDouble(sc.next()); }
64.     static String nln()throws IOException{ return sc.nextLine(); }
65.     static long gcd(long a, long b){ return (b==0)?a:gcd(b,a%b);}
66.     static int gcd(int a, int b){ return (b==0)?a:gcd(b,a%b); }
67.
70.         StringTokenizer st;
71.
74.         }
75.
76.         String next(){
77.             while (st == null || !st.hasMoreElements()){
78.                 try{ st = new StringTokenizer(br.readLine()); } catch (IOException  e){ e.printStackTrace(); }
79.             }
80.             return st.nextToken();
81.         }
82.
83.         String nextLine(){
84.             String str = "";
85.             try{ str = br.readLine(); } catch (IOException e) { e.printStackTrace(); }
86.             return str;
87.         }
88.     }
89. }
RAW Paste Data