50分求助

P1009 [NOIP1998 普及组] 阶乘之和

hyde_AC @ 2023-11-27 21:05:31

#include <bits/stdc++.h>
using namespace std;
int main(){
    long long n,sum_small=1,sum_all=1,a;
    cin >> n;
    for(int i =2;i<=n;i++){
        sum_small*=i;
        sum_all+=sum_small;
    }
    cout << sum_all;
    return 0;
}

by heyx0201 @ 2023-11-27 21:13:41

@hyde_AC NB!


by sdyzpf @ 2023-11-27 21:17:38

@hyde_AC 这题答案之和会超过long long的范围,要使用高精度乘法


|