1 solutions

  • -7
    @ 2024-9-28 11:16:15
    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
        int n,s=0,temp=1;
        cin>>n;
        for(int i=1;i<=n;i++)
        {
            temp*=i;
            //取模于1000000,避免超出范围
            temp%=1000000;
            s+=temp;
            //总和s也需要取模于1000000,避免超出范围
            s%=1000000;
        }
        cout<<s;
        return 0;
    }
    

    Information

    ID
    54
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    3
    Tags
    (None)
    # Submissions
    112
    Accepted
    34
    Uploaded By