标签:des style blog http color java os io
Time Limit: 1000MS | Memory Limit: 10000K | |
Total Submissions: 16638 | Accepted: 3771 |
Description
Input
Output
Sample Input
17 1073741824 25 0
Sample Output
1 30 2
Source
1 #include<cmath> 2 #include<cstdio> 3 #include<cstring> 4 #include<stdlib.h> 5 #include<algorithm> 6 #define LL __int64 7 using namespace std; 8 int main() 9 { 10 //freopen("in.txt","r",stdin); 11 int n,x,y; 12 while(scanf("%d",&n)&&n) 13 { 14 if(n>0) 15 { 16 for(int i=31;i>=1;i--) 17 { 18 x=(int)(pow(n*1.0,1.0/i)+0.5); 19 y=(int)(pow(x*1.0,1.0*i)+0.5); 20 if(n==y) 21 { 22 printf("%d\n",i); 23 break; 24 } 25 } 26 } 27 else 28 { 29 n=-n; 30 for(int i=31;i>=1;i-=2) 31 { 32 x=(int)(pow(n*1.0,1.0/i)+0.5); 33 y=(int)(pow(x*1.0,1.0*i)+0.5); 34 if(n==y) 35 { 36 printf("%d\n",i); 37 break; 38 } 39 } 40 } 41 } 42 return 0; 43 }
还可以用分解质因子的方法来做
POJ 1730 Perfect Pth Powers (枚举||分解质因子),布布扣,bubuko.com
POJ 1730 Perfect Pth Powers (枚举||分解质因子)
标签:des style blog http color java os io
原文地址:http://www.cnblogs.com/clliff/p/3924191.html