麻烦大佬帮忙看一下,只有50分

P1009 [NOIP1998 普及组] 阶乘之和

yuyuyuyu12345 @ 2022-10-10 16:07:13

#include <iostream>
#include <algorithm>
using namespace std;
int f(int n)
{
    if(n<=1) return 1;
    return n*f(n-1);
}
int main()
{
    int n;
    cin>>n;
    int sum=0;
    for(int i=1;i<=n;i++)
    {
        sum+=f(i);
    }
    cout<<sum;
}

by 编码落寞 @ 2022-10-10 16:22:31

@yuyuyuyu12345

数据结果爆int,建议学习下高精度


by yuyuyuyu12345 @ 2022-10-10 16:42:05

@编码落寞 好的,谢谢大佬


|