2 shunfurh shunfurh 于 2017.09.08 11:10 提问

Perfect Pth Powers

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 pth power if, for some integer b, x = bp. Given an integer x you are to determine the largest p such that x is a perfect pth 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 pth power.

Sample Input

17
1073741824
25
0

Sample Output

1
30

1个回答

caozhy
caozhy   Ds   Rxr 2017.09.23 23:26
已采纳
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!
其他相关推荐
poj 1730Perfect Pth Powers(分解质因数)
Perfect Pth Powers Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 16746   Accepted: 3799 Description We say that x is a perfect square if, for some inte
poj1730 - Perfect Pth Powers
想看更多的解题报告: http://blog.csdn.net/wangjian8006/article/details/7870410                                      转载请注明出处:http://blog.csdn.net/wangjian8006 题目大意:要求出一个完美的平方数,完美的平方数是这样的,n = bp的当P最大的时候才是一个完美的
poj1730——Perfect Pth Powers
直接暴力查找。注意负数的存在!#include#include#includeusing namespace std;__int64 n;#define esp 1e-10int result(){ int star=2,end=(int )sqrt((double)n); for(int i=star;i<=end;i++) { if(n%i>=
Perfect Pth Powers
Description We say that x is a perfect square if, for some integer b, x = b 2. Similarly, x is a perfect cube if, for some integer b, x = b 3. More generally, x is a perfect pth power if, for s
Perfect Pth Powers(ZJU_2124)
#include int main(){ double x,y,b,r; int p; while(scanf("%lf",&x)!=-1&&x) {  p=0;  y=x;  if(x   y=-x;  for(b=2;b*b  {   r=b*b;   p=2;   while(r   {    r=r*b;    p++;   }   if(r==y)   {    if(x>0||p%2)
poj-1730 Perfect Pth Powers
题目链接:http://poj.org/problem?id=1730 Perfect Pth Powers Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 13099   Accepted: 2990 Description We say tha
Perfect Pth Powers解题报告
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 pth power if, for some
poj-1730 Perfect Pth Powers
J - Perfect Pth Powers Crawling in process...Crawling failedTime Limit:1000MS    Memory Limit:10000KB    64bit IO Format:%I64d & %I64u SubmitStatus Description We say that x is a perfect
【数论】poj1730 Perfect Pth Powers
传送门:戳我 题目大意:
poj 1730 Perfect Pth Powers
Perfect Pth Powers Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 17353 Accepted: 3980 Description We say that x is a perfect square if, for some integer b, x = b2. Similarly, x is a