4 条题解

  • 0
    @ 2025-10-5 13:54:54

    #include<stdio.h>

    #include<math.h>

    int main(){

    int n,m,a;

    scanf("%d",&n);

    while(n--){

    double x=0;

    scanf("%d",&m);

    for(int i=1;i<=m;i++){

    x=x+log10(i);

    }

    a=x;

    printf("%d\n",a+1);

    }

    return 0;

    }

    • 0
      @ 2023-11-21 22:00:21
      #include<iostream>
      #include<cmath>
      using namespace std;
      int main()
      {
          int t;
          cin >> t;
          while(t--)
          {
              int n;
              cin >> n;
              double wei = 0;
              for(int i = 1 ; i <= n ; i++)
              {
                  wei+=log10(i);
              }
              cout <<(int) wei + 1 << '\n';
          }
      }
      
      • 0
        @ 2023-10-25 19:37:52

        #include<stdio.h>

        #include<math.h>

        int main()

        {

        int n,m;

        scanf("%d",&n);

        double k=0;

        while(n--) {

        scanf("%d",&m);

        for(int i=1;i<=m;i++)

        {

        k+=log10(i);

        }

        printf("%d\n",(int)floor(k)+1);

        k=0;

        }

        return 0;

        }

        • 0
          @ 2023-9-26 21:55:35
          #include <stdio.h>
          #include <math.h>
          int fun(int n) {
              if (n <= 1)
              return 1; // 0和1的阶乘都是1,只有1位数字
              double N = 0;
              for (int i = 2; i <= n; i++)
              N += log10(i); // 使用对数运算计算阶乘的位数
              return (int)floor(N) + 1; // 向下取整并加1,得到位数
          }
          
          int main() {
          	int m;
          	scanf("%d",&m);
          	while(m--){
              int n;
              scanf("%d", &n);
              int N = fun(n);
              printf("%d\n",N);
          	}
              return 0;
          }
          
          • 1

          信息

          ID
          147
          时间
          3000ms
          内存
          128MiB
          难度
          6
          标签
          (无)
          递交数
          748
          已通过
          231
          上传者