求助大佬,这个题一直都是50分,求助,感谢!!

P1009 [NOIP1998 普及组] 阶乘之和

ZJdog @ 2024-02-25 12:36:50

#include <stdio.h>

int main() {
    long long int n, s = 0;
    long long int f[100];
    scanf("%lld", &n);
    int fac = 1;
    for (int i = 1; i <= n; i++) {
        f[i] = fac *= i;
    }
    for (int j = 1; j <= n; j++) {
        s += f[j];
    }
    printf("%lld", s);
    return 0;
}

by Axolotl_awa @ 2024-02-25 12:41:23

@ZJdog 要高精度,光long long是不行的


by Axolotl_awa @ 2024-02-25 12:42:14

@ZJdog 可以去看看题解(不是让你抄


by Rindong @ 2024-02-25 21:13:12

需要实现高精度大整数哦,使用longlong还是会越标的


by ZJdog @ 2024-02-28 09:21:49

谢谢大佬们!!


by PYM20111102 @ 2024-03-20 21:04:31

@ZJdog 那个程序早爆了!


|