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

直接枚举b和p,手算b的p次方即可。。。

Posted by hexiecs at 2015-07-01 23:53:31 on Problem 1730
int main()
{int x;
while(RI(x)!=EOF)
{
if(!x)
        break;
   int p=0;
   if(x>0)
   {
       for(int i=0;i<=65535;i++)
        {int tmp=1;
        for(int j=1;j<=31;j++)
       {tmp=tmp*i;
       if(tmp==x)
       {
           p=j;
           break;
       }
       if(tmp>x)
        break;

        }
        if(p!=0)
           break;
       }
       if(p==0)
        p=1;
   }
   else
   {
       for(int i=-1;i>=-65536;i--)
       {
           int tmp=1;
           for(int j=1;j<=31;j++)
           {
               tmp=tmp*i;
               if(tmp==x)
               {
                   p=j;
                   break;
               }
               if(tmp<x)
                break;
           }
           if(p!=0)
            break;
       }
       if(p==0)
        p=1;
   }

printf("%d\n",p);
}



        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