本地可以,上传就不行了,求求大佬帮忙看看

P1009 [NOIP1998 普及组] 阶乘之和

qi___ye @ 2022-11-28 12:17:23

#include<stdio.h>

int main(){
    int n;
    scanf("%d",&n);
    int a[100]={1};
    int s[100]={};
    for(int i=1;i<=n;i++){
        for(int i1=0;i1<=i;i1++){
            a[i1]*=i;
        }
        for(int i1=0;i1<=100;i1++){
            a[i1+1]+=a[i1]/10;
            a[i1]%=10;
        }
        for(int i1=0;i1<100;i1++){
            s[i1]+=a[i1];
            s[i1+1]+=s[i1]/10;
            s[i1]%=10;
        }
    }
    int b=0;
    for(int i=99;i>=0;i--){
        if(s[i]==0&&b==0){
            continue;
        }
        b++;
        printf("%d",s[i]);
    }

    return 0;
}

by Coffins @ 2022-11-28 12:23:09

阶乘和会爆精度&long long啊,所以用高精


by End_of_time @ 2022-11-28 12:30:19

额,PYTHON是个好东西


|