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

急!Why TLE?怎么解决啊?请教高手指点!!!

Posted by feifei909 at 2008-07-16 12:58:59 on Problem 1730
#include<iostream>
using namespace std;
#include<math.h>
int main()
{
    long x;
    int calculate(long x);
    while(cin>>x,x!=0)
         cout<<calculate(x)<<endl;
    system("pause");
    return 0;
}

int calculate(long x)
{
    float b;
    float p;
    for( b=2; b<= x; b++)
    {
         for( p=1; p< 32; p++)
         {
              if((long)pow(b,p)>x) break;
              if(x== (long)pow(b,p))
              return p;
         }
    }
}

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