| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
郁闷郁闷!WA*5,那位大哥能给点测试数据或指正错误?感激不尽!!_~_(Code Attached)那位大哥能帮忙指正错误?感激不尽!!
#include<stdio.h>
#include<math.h>
__int64 n;
inline int check(int b)
{
__int64 c=1;
while(c<n)c*=b;
if(n==c)return 1;else return 0;
}
int main()
{
int i,result;
double x;
while(scanf("%I64d",&n)==1)
{
if(n==0)break;
if(n<0)n=-n;result=1;
for(i=1;i<=32;i++)
{
x=pow(n,1/(double)i);
if(fabs(x-(int)x)<0.0000000000001&&check((int)x)||
fabs(x-(int)x-1)<0.000000000001&&check((int)x+1))
result=i;
}
printf("%d\n",result);
}
return 0;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator