Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

郁闷郁闷!WA*5,那位大哥能给点测试数据或指正错误?感激不尽!!_~_(Code Attached)

Posted by noskill at 2005-04-09 10:58:09 on Problem 1730
那位大哥能帮忙指正错误?感激不尽!!
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator