Pro.ID21332 TitlePerfect P-th Powers Title链接http://10.20.2.8/oj/exercise/problem?problem_id=21332 AC11 Submit62 Ratio17.74% 时间&空间限制描述We say that x is a perfect square if, for some integer b, x = b2. Similarly, x is a perfect cube if, for some integer b, x = b3. More generally, x is a perfect p-th power if, for some integer b, x = b p. Given an integer x you are to determine the largest p such that x is a perfect p-th power. 输入Each test case is given by a line of input containing x. The value of x will have magnitude at least 2 and be within the range of a (32-bit) int in C, C++, and Java. A line containing 0 follows the last test case. 输出Description We say that x is a perfect square if, for some integer b, x = b2. Similarly, x is a perfect cube if, for some integer b, x = b3. More generally, x is a perfect p-th power if, for some integer b, x = b p. Given an integer x you are to determine the largest p such that x is a perfect p-th power. Input Each test case is given by a line of input containing x. The value of x will have magnitude at least 2 and be within the range of a (32-bit) int in C, C++, and Java. A line containing 0 follows the last test case. Output For each test case, output a line giving the largest integer p such that x is a perfect p-th power. Sample Input 17 Sample Output 1 Source 样例输入17 样例输出1 作者 |