#K86077. Cubed Digit Prime Check

    ID: 36784 Type: Default 1000ms 256MiB

Cubed Digit Prime Check

Cubed Digit Prime Check

You are given a sequence of integers. For each number, compute the sum of the cubes of its digits. That is, for a given integer \(n\) with digits \(d_1, d_2, \dots, d_k\), you need to compute:

\(S = d_1^3 + d_2^3 + \cdots + d_k^3\)

Then determine whether \(S\) is a prime number. If it is prime, output YES; otherwise, output NO.

Example:

For the number 515, the sum would be \(5^3 + 1^3 + 5^3 = 125 + 1 + 125 = 251\), and since 251 is prime, the output should be YES.

inputFormat

The first line of input contains an integer T, the number of test cases. Each of the following T lines contains a single integer.

outputFormat

For each test case, output a single line containing YES if the sum of the cubed digits of the given integer is prime, otherwise output NO.## sample

3
123
9474
372
NO

NO NO

</p>