数的长度---nyoj69

超时

#include <stdio.h>
#include <string.h>
#define M 1000001
int shu[M];

int main()
{
 int n, x, i, j, p, e, m;
 scanf("%d", &n);
 while(n--){
               
            memset(shu, 0, sizeof(shu));
   shu[1] = 1;
   scanf("%d", &x);
#if 0
   for(i = 1, p = 1; i <= x; ){

for(j = 1; j <= p; j++, i++)/*将大数的各个位数与乘数相乘*/
     {
      shu[j] *= i;
      if(shu[j] >= 10)
      {
       shu[j+1] = shu[j] / 10;
       shu[j] %= 10;
       p++;
      }
     
     }
     
   }
#endif
   p = 1;
   for(i = 1; i <= x; i++)
   {
    e = 0;
    m = 0;
    for(j = 1; j <= p; j++)
    {
     e = shu[j] * i + m;
     shu[j] = e % 10;
     m = e / 10;
     if(j == p && m)
     {
      p++;
     }
    
    }

}
   printf("%d\n", p);

}
 return 0;
}

上一篇:linux环境下oracle 11g 静默安装


下一篇:textContent 与innerText