2 条题解

  • 0

    #include <iostream>
    #include <cmath>
    using namespace std;

    int GetLength(double x);

    int main()
    {
    int n; cin>>n;
    double y=1;
    for(int x=2; x<=n; x++)
    y=y*x;
    cout<<GetLength(y)<<endl;
    return 0;
    }
    int GetLength(double x)
    {
    int n=0;
    while(x>=1) // !!!!
    n++, x/=10;
    return n;
    }

    int GetLength(int x)
    {
    int n; cin>>n;
    double len=0;
    for(int i=1; i<=n; i++)
    len += log(i)/log(10);
    cout << (int)len + 1;
    return 0;
    }

  • -2
    #include <iostream>
    #include <cmath>
    using namespace std;
    int GetLength(double x);
    int main()
    {
    int n; cin>>n;
    double y=1;
    for(int x=2; x<=n; x++)
    y=y*x;
    cout<<GetLength(y)<<endl;
    return 0;
    }
    int GetLength(double x)
    {
    int n=0;
    while(x>=1) // !!!!
    n++, x/=10;
    return n;
    }
    int GetLength(int x)
    {
    int n; cin>>n;
    double len=0;
    for(int i=1; i<=n; i++)
    len += log(i)/log(10);
    cout << (int)len + 1;
    return 0;
    }
    
    
  • 1

信息

ID
1089
难度
8
分类
(无)
标签
递交数
621
已通过
57
通过率
9%
被复制
6
上传者