题目:http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1130
暴力计算一会溢出,二会超时,所以这里用到了斯特林近似
#include<iostream> #include<math.h> using namespace std; const double e=2.718281828459; const double pi=3.1415926535898; int main() { int n; cin>>n; while(n--) { __int64 x,ans; cin>>x; ans=0.5*log10(2*pi*x)+1.0*x*log10(x*1.0/e)+1; cout<<ans<<endl; } return 0; }