#P10720. [GESP202406 五级] 小杨的幸运数字

[GESP202406 五级] 小杨的幸运数字

Background

Corresponding multiple-choice and true/false problems: https://ti.luogu.com.cn/problemset/1153.

Problem Description

Xiao Yang believes that his lucky number should have exactly two distinct prime factors. For example, 12=2×2×312 = 2 \times 2 \times 3 has prime factors 2,32, 3, which are exactly two distinct prime factors, so 1212 is a lucky number. However, 30=2×3×530 = 2 \times 3 \times 5 has prime factors 2,3,52, 3, 5, which does not meet the requirement, so it is not a lucky number.

Xiao Yang now has nn positive integers, and he wants to know whether each positive integer is his lucky number.

Input Format

The first line contains a positive integer nn, representing the number of positive integers.

The next nn lines each contain one positive integer.

Output Format

Output nn lines. For each positive integer, if it is a lucky number, output 11; otherwise output 00.

3
7
12
30
0
1
0

Hint

Sample Explanation

The prime factors of 77 are 77, which is only one kind.

The prime factors of 1212 are 2,32, 3, which is exactly two kinds.

The prime factors of 3030 are 2,3,52, 3, 5, which is three kinds.

Constraints

Subtask ID Percentage nn Range of positive integers
11 40%40\% 100\leq 100 105\leq 10^5
22 60%60\% 104\leq 10^4 106\leq 10^6

For all testdata, it is guaranteed that 1n1041 \leq n \leq 10^4, and each positive integer aia_i satisfies 2ai1062 \leq a_i \leq 10^6.

Translated by ChatGPT 5