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

不用判断n的大小 0ms ac

Posted by j_will at 2009-04-25 15:49:09 on Problem 1423
In Reply To:这个程序需要改进,否则wa,下面这样就过了:) Posted by:watt at 2007-03-17 17:31:21
#include<iostream>
#include<cmath>
using namespace std;
const double e = 2.7182818284590452354, pi = 3.141592653589793239;
double strling_digits_num(int n)
{
	return log10(2*pi*n)/2.0+n*(log10(n/e));
}

int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		int n;
		cin>>n;
		double m=0;
		m=strling_digits_num(n);
		int answer=(int)m;
		//注意!!!!10的n次方有n+1位数字
		answer++;
		cout<<answer<<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