NYOJ69-数的长度 2
1 #include<stdio.h> 2 #include<math.h> 3 int strrling(int n) 4 { 5 const double p=acos(-1.0); 6 double c1=log10(2*p); 7 double c2=0.434294481903; 8 double c3=log10(1.0*n); 9 int s=1; 10 if(n>3) 11 s=(int)((c3+c1)/2+n*(c3-c2)+1); 12 return s; 13 } 14 int main() 15 { 16 int n; 17 scanf("%d",&n); 18 while(n--) 19 { 20 int m; 21 scanf("%d",&m); 22 printf("%ld\n",strrling(m)); 23 } 24 return 0; 25 }