50分 求指导

P1009 [NOIP1998 普及组] 阶乘之和

renli0426 @ 2024-11-22 20:00:00

include<bits/stdc++.h>

using namespace std; int main () { int n , sum = 0 ,fact = 1; cin >> n; for ( int i = 1; i <= n ; ++ i) { fact *= i; sum += fact;

}
cout << sum << endl;
return 0;

}

#include<bits/stdc++.h>
using namespace std;
int main ()
{
    int n , sum = 0 ,fact = 1;
    cin >> n;
    for ( int i = 1; i <= n ; ++ i)
    {
        fact *= i;
        sum += fact;

    }
    cout << sum << endl;
    return 0;
}

by wky_wsy @ 2024-11-22 20:02:16

要用高精度


by Camellya @ 2024-11-22 22:13:49

你要用高精度,尝试把每一个数分别分给不同的数组,然后再去累乘


by Hydrogen_H @ 2024-11-23 21:39:41

题解里的预言实现了


|