qwq为何50分啊啊啊啊我要发癫了

P1009 [NOIP1998 普及组] 阶乘之和

DESTRUCTION_WA @ 2024-07-03 12:56:02

#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
using namespace std;
int main() {

    int n;
    long long sum = 0,sum1 = 1;
    scanf("%d", &n);
    if(n == 0){
        printf("1");
        return 0;
    }
    for(int i = 1;i <= n;i++){
        for(int j = 1;j <= i;j++){
            sum1 *= j;
        }
        sum += sum1;
        sum1 = 1;
    }
    printf("%d", sum);
    return 0;
}

by lxrllllll @ 2024-07-03 12:57:22

哪道题? @bored_frank


by DESTRUCTION_WA @ 2024-07-03 12:58:50

阶乘之和 P1009


by wfirstzhang @ 2024-07-03 12:59:44

如果 n=50,那么正确结果是 31035053229546199656252032972759319953190362094566672920420940313


by wfirstzhang @ 2024-07-03 13:01:01

在说你这 printf 用的也不对,应该是 printf("%lld", sum);


by DESTRUCTION_WA @ 2024-07-03 13:01:24

@wfirstzhang 我都已经开long long了-_-


by wfirstzhang @ 2024-07-03 13:03:42

LLONG_MAX == 9223372036854775807


by lxrllllll @ 2024-07-03 13:05:07

@bored_frank 第一:题目明确说明要使用高精度, 而且数据确实需要用到高精度, long long不够长 第二:题目说n为正整数, 所以一开始的特判很多余


by DESTRUCTION_WA @ 2024-07-03 13:06:45

@wfirstzhang

……所以开什么?

我只知道int和long long


by wfirstzhang @ 2024-07-03 13:11:51

@bored_frank 高精度。本质上就是模拟手工运算(其实也有二进制高精)。


by DESTRUCTION_WA @ 2024-07-03 13:16:15

@wfirstzhang ……好吧我不会


| 下一页