Is it a power?

Write a program to tell if a natural number nn is a non-trivial power, that is, if it can be expressed as xmx^m, where both xx and mm are natural numbers, and m2m \ge 2. For instance, some non-trivial powers are 243=35243 = 3^5, 400=2452=(2251)2400 = 2^4 5^2 = (2^2 5^1)^2, 216000=263353=(223151)3216000 = 2^6 3^3 5^3 = (2^2 3^1 5^1)^3, and 1866240000=2123654=(263352)21866240000 = 2^{12} 3^6 5^4 = (2^6 3^3 5^2)^2. By contrast, 3, 200=2352200 = 2^3 5^2, and 432000=273353432000 = 2^7 3^3 5^3 are not non-trivial powers.

Input

Input consists of several cases, each with a natural number nn between 2 and 10610^6.

Output

Print every nn followed by “yes” or “no”, depending on whether it is a non-trivial power.

Observation

You should not use the mathematical function @pow()@ nor any alike function to solve this problem.

Hint

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.

Problem information

Author: Unknown
Translator: Salvador Roura

Generation: 2026-01-25T11:06:08.884Z

© Jutge.org, 2006–2026.
https://jutge.org