80分 求助大佬们!!!

P1303 A*B Problem

spessert @ 2024-03-11 18:09:48

第一个测试点错了

#include<bits/stdc++.h>
using namespace std;
string A,B;
int a[1000000],b[1000000],c[1000000],la,lb,lc;
int main()
{
    cin>>A>>B;
    la=A.size();
    lb=B.size();
    lc=la+lb;
    for(int i=0;i<la;i++)
      a[la-i]=A[i]-'0';
    for(int i=0;i<lb;i++)
      b[lb-i]=B[i]-'0';
    for(int i=1;i<=la;i++)
     for(int j=1;j<=lb;j++)
     {
         c[i+j-1]+=a[i]*b[j];
         c[i+j]+=c[i+j-1]/10;
         c[i+j-1]%=10;
     }
     while(c[lc]==0&&lc>0) lc--;
     for(int i=lc;i>0;i--)
      cout<<c[i];
    return 0;
}

by chenshenqi @ 2024-03-11 18:16:15

a=int(input())
b=int(input())
print(a+b)

by chenyyegg @ 2024-03-11 18:33:34

@spessert

while(c[lc]==0&&lc>0) lc--;

改为:

while(c[lc]==0&&lc>1) lc--;

by chenyyegg @ 2024-03-11 18:36:09

@spessert 求关QWQ


by spessert @ 2024-03-16 10:27:45

@chenyyegg 感谢!!!


by Hamdi @ 2024-06-21 20:00:34

你好像没特判0


|