50分!大佬求助!!!

P1009 [NOIP1998 普及组] 阶乘之和

YYYabc @ 2023-04-29 19:48:56

#include <iostream>
using namespace std;

int f(int x)
{
    if (x <= 1) return 1;
    return x * f(x - 1);
}

int main()
{
    int n;
    cin >> n;
    int sum = 0;
    for (int i = 1; i <= n; i++)
    {
        sum += f(i);
    }
    cout << sum << endl;
    return 0;
}

by zfj123456 @ 2023-04-29 19:57:34

要高精度啊!!!题里都明确说了@YYYabc


by sherry_lover @ 2023-04-29 20:24:20

@YYYabc 高精度!!!


by chenxinuo @ 2023-05-04 19:52:46

高精度!!!!!!7


by kkkkksc03_is_sb @ 2023-05-10 19:18:49

高精度!!!


by zzhlzy200912 @ 2023-05-13 15:47:33

@YYYabc python一行就能搞定 print(reduce(lambda x,y:x+y,[reduce(lambda x,y:x*y,range(1,i+1)) for i in range(1, int(raw_input())+1)]))


by cyt_666 @ 2023-05-21 22:39:54

@zzhlzy200912 tql


|