求C大佬解决

P1009 [NOIP1998 普及组] 阶乘之和

1357911BCC @ 2024-09-27 20:55:49

#include <bits/stdc++.h>
using namespace std;
long long ret = 0;
int jiecheng(long long n){
    int num = 1;
    for(int i = 1;i <= n;i++){
        num *= i;
    }
    return num;
}

int main() {
    int n;
    cin >> n;
    for(int i = 1;i <= n;i++){
        ret += jiecheng(i);
    }
    cout << ret;
    return 0;
}

怎么错啦? 求解


by NC20061226 @ 2024-09-27 20:59:19

@1357911BCC 建议食用高精度


by cyq32ent @ 2024-09-27 20:59:21


by 1357911BCC @ 2024-10-11 21:27:50

@cyq32ent 我开的long long啊


by cyq32ent @ 2024-10-12 17:55:54

@1357911BCC long long也爆了


|