玄关求条

P1009 [NOIP1998 普及组] 阶乘之和

lihongxing @ 2024-10-01 06:56:27

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    long long s=0;
    long long sa=0;
    for(int i=1;i<=n;i++)
    {

        for(int j=1;j<=i;j++)
        {
            sa*=j;
        }
        s+=sa;

    }
    cout<<s<<endl;
}

by skyx @ 2024-10-01 07:33:21

@lihongxing 0乘任何数都得0


by yangyuhan @ 2024-10-01 08:12:44

这个应该是新手(哭笑不得)


by lihongxing @ 2024-10-02 16:33:08

@yangyuhan 多练就好了


by yangyuhan @ 2024-10-04 17:24:39

@lihongxing 确实需要时间,我一开始也老犯这个毛病


|