luogu#P8054. A 质因数

A 质因数

Problem Description

Define f(x)f(x) as the number of prime factors of xx after prime factorization, counting multiplicities. For example, f(6)=2f(6)=2 and f(12)=3f(12)=3.

Specifically, let x=p1a1p2a2pkakx=p_1^{a_1}p_2^{a_2}\cdots p_k^{a_k}, where p1,p2,,pkp_1,p_2,\ldots,p_k are pairwise distinct primes. Then f(x)=a1+a2++akf(x)=a_1+a_2+\cdots + a_k.

Given a number nn, determine whether there exists an integer mm with 1<m<n1<m<n such that f(m)>f(n)f(m)>f(n).

Input Format

The first line contains an integer TT, which represents the number of test cases.

The next TT lines each contain a positive integer nn.

Output Format

Output TT lines. For the ii-th test case, if the given nn has some mm satisfying 1<m<n1<m<n and f(m)>f(n)f(m)>f(n), output a single number 11 on one line; otherwise output a single number 00 on one line.

6
2
3
4
5
12
514
0
0
0
1
0
1

Hint

Sample Explanation #1

f(2)=1f(2)=1, and there is no 1<x<21<x<2 with f(x)>1f(x)>1.

f(3)=1f(3)=1, and there is no 1<x<31<x<3 with f(x)>1f(x)>1.

f(4)=2f(4)=2, and there is no 1<x<41<x<4 with f(x)>2f(x)>2.

f(5)=1f(5)=1, and f(4)=2f(4)=2 exists.

f(12)=3f(12)=3, and there is no 1<x<121<x<12 with f(x)>3f(x)>3.

f(514)=2f(514)=2, and f(114)=3f(114)=3 exists.

Constraints

For all testdata, 1T1041\leq T\leq 10^4 and 2n10182\leq n\leq 10^{18}. The detailed constraints are as follows:

  • Subtask #1 (25 pts): T,n10T,n\le 10.
  • Subtask #2 (35 pts): n105n\le 10^5.
  • Subtask #3 (15 pts): T10T\le 10, and nn is generated uniformly at random in [2,1018][2,10^{18}].
  • Subtask #4 (25 pts): No additional constraints.

Translated by ChatGPT 5