| ||||||||||
| 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 | |||||||||
急!Why TLE?怎么解决啊?请教高手指点!!!#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator