CF BUDDY
← Problems·

1846E1 · Rudolf and Snowflakes (simple version)

1300 · brute force, implementation, math

Problem: This is a simple version of the problem. The only difference is that in this version n106n \le 10^6.

One winter morning, Rudolf was looking thoughtfully out the window, watching the falling snowflakes. He quickly noticed a certain symmetry in the configuration of the snowflakes. And like a true mathematician, Rudolf came up with a mathematical model of a snowflake.

He defined a snowflake as an undirected graph constructed according to the following rules:

  • Initially, the graph has only one vertex.
  • Then, more vertices are added to the graph. The initial vertex is connected by edges to kk new vertices (k>1k > 1).
  • Each vertex that is connected to only one other vertex is connected by edges to kk more new vertices. This step should be done at least once.

The smallest possible snowflake for k=4k = 4 is shown in the figure.

After some mathematical research, Rudolf realized that such snowflakes may not have any number of vertices. Help Rudolf check if a snowflake with nn vertices can exist.

Input Format: The first line of the input contains an integer tt (1t1041 \le t \le 10^4) — the number of test cases.

Then follow the descriptions of the test cases.

The first line of each test case contains an integer nn (1n1061 \le n \le 10^6) — the number of vertices for which it is necessary to check the existence of a snowflake.

Output Format: Output tt lines, each of which is the answer to the corresponding test case — "YES" if there exists such k>1k > 1 for which a snowflake with the given number of vertices can be constructed; "NO" otherwise.

Sample Cases

Case 1

Input

9
1
2
3
6
13
15
255
10101
1000000

Output

NO
NO
NO
NO
YES
YES
YES
YES
NO

Similar problems

00:00:00
Loading editor…
Welcome! I'm your coding tutor for this problem. Use the chips below to reveal stored hints or get AI feedback on your code. I'll guide you step by step — never giving away the solution.

Sign in to unlock AI tutor feedback