Write a program to tell if a natural number is a non-trivial power, that is, if it can be expressed as , where both and are natural numbers, and . For instance, some non-trivial powers are , , , and . By contrast, 3, , and are not non-trivial powers.
Input consists of several cases, each with a natural number between 2 and .
Print every
followed by “yes” or “no”, depending on
whether it is a non-trivial power.
You should not use the mathematical function @pow()@ nor any alike function to solve this problem.
A possible solution uses a variant of the sieve of Eratosthenes to precompute a prime factor of each number before starting to read the input.
Input
243 400 216000 3 200 432000 1000000 999999
Output
243 yes 400 yes 216000 yes 3 no 200 no 432000 no 1000000 yes 999999 no