3 solutions

  • 0
    @ 2026-8-26 20:39:57
    #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;
            temp%=1000000;
            s+=temp;
             s%=1000000;
        }
        cout<<s;
        return 0;
    }
    • 0
      @ 2025-10-8 10:43:22
      #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;
              temp%=1000000;
              s+=temp;
               s%=1000000;
          }
          cout<<s;
          return 0;
      }
      
    • -10
      @ 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;
      }
      
      • 1

      Information

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