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

Re:请问怎样不超时

Posted by ytmsdy at 2008-09-24 15:44:36 on Problem 1338
In Reply To:请问怎样不超时 Posted by:SinsongLew at 2007-04-15 14:26:25
> #include<iostream.h>
> void main()
> {
> 	int N[50],n=1,i=0,num=0,status=1;
> 	while(n)
> 	{
> 		cin>>n;
> 		if(n!=0)
> 		{
> 			N[i]=n;
> 	     	i++;
> 		}
> 	}
> 	for(int j=0;j<i;j++)
> 	{
> 		if(N[j]<=6)
> 			cout<<j+1<<endl;
> 		else
> 		{
> 			num=6;
> 			int k=7;
> 			while(num!=N[j])
> 			{
> 				status=1;
> 				int p=k,mark=0;
> 				while(status)
> 				{
> 					mark=p;
> 				   if(p%2==0)
> 					  p=p/2;
> 				   if(p%3==0)
> 					   p=p/3;
> 					if(p%5==0)
> 					  p=p/5;
> 					if(p==mark||p==1) status=0;
> 				}
> 				if(p==1) num++;
> 				++k;
> 			}
> 			cout<<k-1<<endl;
> 		}
> 	}
> }

打表~~~~~~~~~~~~


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