求大佬指导 qwq

P1009 [NOIP1998 普及组] 阶乘之和

zhengshiy @ 2024-10-22 18:04:39

#include <bits/stdc++.h>

using namespace std;

int main()

{

    int a=1,c,n;

    long z;

    cin>>n; 

    for(a=1;a<=n;a++)

    {

        z==1;

        for(c=1;c<=a;c++)

        {

            z=c+z;  

        }   

    }

   cout<<z<<endl;

    return 0;

}

by zhengshiy @ 2024-10-22 18:17:05

更新了,求指导 qwq

#include <bits/stdc++.h>

using namespace std;

int main()

{   

    int i,j,n; 

    long z=1,s=0; 

    cin>>n; 

    for(i=1;i<=n;i++)

    {

        z==1;

        for(j=1;j<=i;j++)

        {

            z=z*j;

        }

        s=s+z;  

    }

   cout<<s<<endl;

   return 0;

}

by HEzzz @ 2024-10-22 18:17:36

@chengguanming

要用高精度


|