1 条题解

  • 0
    @ 2025-4-4 13:20:02
    #include <bits/stdc++.h>
    using namespace std;
    int n;
    int len, a[40005];
    int main()
    {
        cin >> n;
        // 高精度的数初始化为 1
        len = 1;
        a[0] = 1;
        // 每次乘以 t
        for (int t = 1; t <= n; t++)
        {
            for (int i = 0; i <= len - 1; i++)
                a[i] *= t;
            for (int i = 0; i <= len - 2; i++)
            {
                a[i + 1] += a[i] / 10;
                a[i] %= 10;
            }
            while (a[len - 1] >= 10)
            {
                a[len] = a[len - 1] / 10;
                a[len - 1] %= 10;
                len++;
            }
        }
        for (int i = len - 1; i >= 0; i--)
            cout << a[i];
        return 0;
    }
    
    • 1

    信息

    ID
    13412
    时间
    1000ms
    内存
    128MiB
    难度
    9
    标签
    (无)
    递交数
    10
    已通过
    5
    上传者