1 #include<stdio.h> 2 #include<math.h> 3 int main() 4 { 5 int t,n,i; 6 double sum,a,b,c; 7 a=0.434294481903; 8 b=0.798179868358; 9 scanf("%d",&t); 10 while(t--) 11 { 12 scanf("%d",&n); 13 c=log10(n); 14 sum=1.0; 15 if(n>3) 16 sum=(c+b)/2+n*(c-a)+1; 17 printf("%d ",(int)sum); 18 } 19 return 0; 20 }
1 #include<stdio.h> 2 #include<math.h> 3 int main() 4 { 5 int t,n,i; 6 double sum; 7 scanf("%d",&t); 8 while(t--) 9 { 10 scanf("%d",&n); 11 sum=1.0; 12 for(i=2;i<=n;i++) 13 sum+=log10(i); 14 printf("%d ",(int)sum); 15 } 16 return 0; 17 }