80分求解

P1303 A*B Problem

xiazhengyu @ 2023-07-16 16:31:20

哪错了???


#include<bits/stdc++.h>
using namespace std;
#define maxx 1145
char sa[maxx],sb[maxx];
int la,lb,lc, jw,f,w,a[maxx],b[maxx],c[maxx*maxx];
int main()
{
    scanf("%s",sa);
    scanf("%s",sb);
    la=strlen(sa);
    lb=strlen(sb);
    for (int i=0;i<la;i++)
    {
        a[la-i-1]=sa[i]-'0';
    }
    for (int i=0;i<lb;i++)
    {
        b[lb-i-1]=sb[i]-'0';
    }
    jw=0;
    for (int i=0;i<la;i++)
    {
        for (int j=0;j<lb;j++)
        {
            f=a[i]*b[j];
            jw=f/10;
            f%=10;
            w=i+j;
            c[w]=c[w]+f;
            c[w+1]=c[w+1]+jw+c[w]/10;
            c[w]%=10;
        }
    }
    lc=la+lb;
    while(c[lc]==0)lc--;
    if(lc<0)
    {
        printf("0");
    }
    else
    for(int i=lc;i>=0;i--)
    {
        printf("%d",c[i]);
    }
    return 0;
}

by wangjiawen @ 2023-07-16 16:35:28

叫你臭,范围是10^2000,你只开到了10^1145。验证码88t8祭


by xiazhengyu @ 2023-07-16 16:35:53

找到问题了: 把1145改成5000就过了。 嘻嘻!


by xiazhengyu @ 2023-07-16 16:37:12

@wangjiawen 谢谢❥(^_-)


by Youth_Glory @ 2023-07-16 16:48:16

《因为臭所以WA,结论:臭死了(确信)》


|