Hide

Problem B
Kaprekar Numbers

A Kaprekar number is a non-negative integer $k$ with the property that the digits of $k^2$ can be split into left and right parts that add up to $k$. The right part must be nonzero, although it may contain leading zeros. The left part can be zero.

  • For example, $1$ is a Kaprekar number. $1^2 = 1$; the right 1 digit forms 1; the left 0 digits form 0; and $1 + 0 = 1$.

  • $99$ is also a Kaprekar number. $99^2 = 9\, 801$; the right 2 digits form 1; the left 2 digits form 98; and $1 + 98 = 99$.

  • $4\, 879$ is also a Kaprekar number. $4\, 879^2 = 23\, 804\, 641$; the right 5 digits form $4\, 641$; the left 3 digits form $238$; and $4\, 641 + 238 = 4\, 879$.

  • However, $100$ is not a Kaprekar number. $100^2 = 10\, 000$; the right 2 digits form 0; the left 3 digits form 100; and $0 + 100 = 100$. But recall that the right part must be nonzero.

Given a non-negative integer $k$, your task is to determine whether $k$ is a Kaprekar number.

Input

Input begins with a number $n$ on a single line, denoting the quantity of numbers to test, with $1 \leq n \leq 100$. $n$ lines follow, each of which contains a single integer $k$, $1 \leq k \leq 10^6$.

Output

For each line, output YES if that integer is a Kaprekar number, or NO if it is not.

Sample Input 1 Sample Output 1
2
99
100
YES
NO

Please log in to submit a solution to this problem

Log in