#K50077. Digit Swap Square
Digit Swap Square
Digit Swap Square
You are given q queries. For each query, you are provided with a positive integer. Your task is to determine whether the integer itself or any number obtained by swapping exactly two digits (only one swap allowed) of the number is a perfect square.
A number is a perfect square if it can be expressed in the form $k^2$, where $k$ is a non-negative integer. For example, 16 is a perfect square since $4^2 = 16$.
For each query, output YES
if the given number or one of its one-swap variants is a perfect square; otherwise, output NO
.
inputFormat
The input is read from standard input. The first line contains a single integer q
, the number of queries. The next q
values (which may be space-separated or on separate lines) represent the numbers to be checked.
outputFormat
For each query, print on a separate line either YES
or NO
indicating whether a perfect square can be obtained from the number itself or by swapping exactly two digits.
3
13 82 144
NO
NO
YES
</p>