#include<stdio.h> #include<math.h> #define PI 3.14159265 int num,ans; void count_factorial() { double t; t = (num*log(num) - num + 0.5*log(2*num*PI))/log(10); ans= (int)t+1; printf("%d\n",ans); } int main() { int i,n; scanf("%d",&n); for( i=1 ; i<=n ; i++ ) { scanf("%d",&num); count_factorial(); } return 0; } //c++编译错误,g++就ac #include <iostream> #include <math.h> using namespace std; int main() { int i,j,k,T; cin>>T; while(T--) { int num; cin>>num; double sum = 0.0; for(i=1;i<=num;i++) sum += log10(i); int ans =(int)sum+1; cout<<ans<<endl; } return 0; }