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:根据stirling来做

Posted by 8013 at 2003-12-14 10:52:14 on Problem 1423
In Reply To:Re:这样也tle 郁闷!!!怎么能不超时阿!! Posted by:first at 2003-12-13 19:17:19
> #include <iostream>
> using namespace std;
> void main()
> {
> 	long double ans;
> 	int n,times,i,digits;
> 	cin>>times;
> 	while(times--)
> 	{
> 		cin>>n;
> 		ans=1.0;
> 		digits=0;
> 		for(i=2;i<=n;i++)
> 		{
> 			ans*=i;
> 			if(ans>=10000000.0)
> 			{
> 				digits+=7;
> 				ans/=10000000.0;
> 			}
> 			else if(ans>=1000000.0)
> 			{
> 				digits+=6;
> 				ans/=1000000.0;
> 			}
> 		    else if(ans>=100000.0)
> 			{
> 				digits+=5;
> 				ans/=100000.0;
> 			}
> 		 else if(ans>=10000.0)
> 			{
> 				digits+=4;
> 				ans/=10000.0;
> 			}
> 			else if(ans>=1000.0)
> 			{
> 				digits+=3;
> 				ans/=1000.0;
> 			}
> 		else	if(ans>=100.0)
> 			{
> 				digits+=2;
> 				ans/=100.0;
> 			}
> 		else	if(ans>=10.0)
> 			{
> 				digits+=1;
> 				ans/=10.0;
> 			}
> 		
> 		}
> 		digits++;
> 		cout<<digits<<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