#P9913. Square Cutting Challenge
Square Cutting Challenge
Square Cutting Challenge
Given a positive integer n, determine whether a square can be subdivided into n smaller squares (the sizes of the smaller squares do not need to be equal). A subdivision is performed by making cuts that are line segments with endpoints either on the boundary of the original square or on a previously made cut.
It is known that such a subdivision is possible if and only if n is not equal to 2, 3, or 5. For example, when n = 1 or n = 4 the subdivision is obvious, while for n = 2, 3, or 5 it is impossible. You are given several test cases.
Input: The first line contains an integer T representing the number of test cases. Then T lines follow, each containing a positive integer n.
Output: For each test case, output a single line containing Yes
if the square can be divided into n smaller squares, otherwise output No
.
Note: All formulas are in LaTeX format. For instance, the condition for subdivision can be expressed as: \( n \in \mathbb{Z}^+ \setminus \{2,3,5\} \).
inputFormat
Input starts with an integer T
(the number of test cases), followed by T
lines. Each of these lines contains a positive integer n
.
Format:
T n1 n2 ... nT
outputFormat
For each test case, output a single line with Yes
if the square can be subdivided into n
smaller squares, or No
if it cannot.
sample
4
1
2
6
5
Yes
No
Yes
No
</p>