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

3100_Problem

Posted by Egpt at 2009-03-14 00:41:48
Hi , 

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:
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