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

这个题目,不可能tle的,难道还有更好的算法,大家看看我的

Posted by first at 2003-12-15 13:43:16 on Problem 1401
void main() 
{ 
	int N,d,num5;
	int mult5[12];
	mult5[0]=5;
	int i;
	for(i=1;i<12;i++)
		mult5[i]=mult5[i-1]*5;
	cin>>N;
	while(N--)
	{   
        cin>>d;
		num5=0;
	    for(i=0;i<12;i++)
			if(d>=mult5[i])
			{
				num5+=d/mult5[i];
			}
			else
			  break;
		cout<<num5<<endl;
	}
	
}
这样tle
while(N--)
	{   
                  cin>>d;
		num5=0;
                  t=d/5;
                           while(t)
			{
				num5+=t;
                                     t/=5;
			}
				cout<<num5<<endl;
	}


这样也tle ft了 5555 怎么做阿

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