zoukankan      html  css  js  c++  java
  • 数的长度---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 ", p);

     }
     return 0;
    }

  • 相关阅读:
    iOS:hidesBottomBarWhenPushed的正确用法
    清理缓存
    iOS常见问题(2)
    iOS常见问题(1)
    Xcode文档下载与安装路径
    文本属性Attributes
    NSAttributedString
    protocol
    类的本质、description方法、SEL、NSLog输出增强
    分类-Category
  • 原文地址:https://www.cnblogs.com/the-one/p/3275532.html
Copyright © 2011-2022 走看看