| ||||||||||
| 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 | |||||||||
3100_ProblemHi ,
I need help in this problem , I solved it but get Run time error .
I don't know where is the problem in my code.
#include<iostream>
#include<cmath>
using namespace std ;
int main()
{
int N , P , count , c , max1 , max2 , res , j ,Seq[1000] , Power ;
while(cin>>N>>P)
{
if(N==0&&P==0)break;
j=1 ;
Power=count=0 ;
while(Power<=N)
{
Power=pow((double) j , P);
j++ ;
Seq[++count]=Power ;
}
max1 = N-Seq[count-1] ;
max2 = Seq[count]-N;
if(max1<=max2)
{
res=Seq[count-1] ;
c=count-1 ;
}
else if(max1>max2)
{
res=Seq[count] ;
c=count ;
}
while(res>c &&c!=0)
res/=c ;
cout<<res<<endl;
}
return 0;
}
---------------
thanks in advance
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator