Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
不用判断n的大小 0ms acIn 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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator