最后一个点WA了,求大佬助我一臂之力

P1009 [NOIP1998 普及组] 阶乘之和

liujiazhi @ 2023-09-10 19:02:49

#include<bits/stdc++.h>
using namespace std;
short x[10],y[105],z[105],u[105];
int main()
{
    int j,i,h,n,l=100,c=0;
    bool f=false;
    cin>>n;
    y[1]=1;
    while (c!=n)
    {
        c++;
        x[0]=c%10;
        x[1]=c/10;
        for (j=0;j<=1;j++)  //first
        {
            for (i=1;i<=l;i++)
            {
                u[i+j]+=x[j]*y[i];
                u[i+j+1]+=(u[i+j]/10);
                u[i+j]%=10;
            }
        }
        for (i=1;i<=l;i++)
        {
            y[i]=u[i];
        }
        memset(u,0,sizeof(u));

        f=false;
        for (i=l;i>=1;i--)
        {
            if (f==false&&y[i]==0) continue;
            else f=true;
            z[i]+=y[i];
            z[i+1]+=(z[i]/10);
            z[i]%=10;
        }
    }
    f=false;
    for (i=l;i>=1;i--)
    {
        if (f==false&&z[i]==0) continue;
        else f=true;
        cout<<z[i];
    }
    if (f==false) cout<<"0";
    return 0;
}

by heyx0201 @ 2023-09-10 19:19:44

打点注释,看不懂……


|