大佬救命,最后两个点WA

P1303 A*B Problem

jennycai13 @ 2022-07-08 10:21:23

#include<iostream>

#include<cstdio>

#include<cstring>

const int N=999999;

int a[N],b[N],c[N];

int lena,lenb,lenc;

char a1[N],b1[N];

void chengfa()

{
    int i,j,k;

    memset(c,0,sizeof(c));

    for(i=0;i<=lenb;i++)                   {                 
        for(j=0;j<=lena;j++)

        {
            c[i+j]=a[i]*b[j]+c[i+j];

            c[i+j+1]=c[i+j]/10+c[i+j+1];

            c[i+j]=c[i+j]%10;

        }
    }
    while(c[lenc]==0 and lenc>0)lenc--;

    for(int i=lenc;i>=0;i--)printf("%d",c[i]);

}

int main()

{

    scanf("%s%s",&a1,&b1);

    memset(a,0,sizeof(a));

    memset(b,0,sizeof(b));

    lena=strlen(a1);lenb=strlen(b1);

    lenc=lena+lenb;

    for(int i=0;i<lena;i++)a[i]=a1[lena-i-1]-'0';

    for(int i=0;i<lenb;i++)b[i]=b1[lenb-i-1]-'0';

    chengfa();

} 

by 137l2108b6546l @ 2022-07-08 10:27:36

不知道


by jennycai13 @ 2022-07-08 10:41:48

321 1的例子不行


|