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 180365 at 2012-07-03 23:43:34 on Problem 1423
In Reply To:其实这道题可以用这个公式 Posted by:slp at 2010-09-14 22:34:35
> 其实这道题可以用这个公式
> tmp = sum( log10(i) ) 0<i<=n
> len(n!)=(int)(tmp)+1
> 打表即可过了...    500ms
> 公式的证明我还不会,求证明:
为什么我的超时?
#include<iostream>   
#include<cmath> 
using namespace std;  
int main()   
{
	int n,i,t;
	double d;
	cin>>t;
	for(int a=0;a<t;a++)
	{
		cin>>n;
		d=0;
		for(i=1;i<=n;i++)   
			d+=log10((double)i);
		cout<<(int)d+1<<endl;
	} 
	//system("pause");
	return 0;
}

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