yaoyang007 @ 2022-10-27 19:44:01
#include<cstdio>
#include<cstring>
using namespace std;
char s1[40000],s2[40000];
int a[40000],b[40000],c[40000];
int main()
{
scanf("%s%s",s1,s2);
int la=strlen(s1);
int lb=strlen(s2);
for(int i=1;i<=la;i++)
a[i]=s1[la-i]-'0';
for(int i=1;i<=lb;i++)
b[i]=s2[lb-i]-'0';
for(int i=1;i<=la;i++)
for(int j=1;j<=lb;j++)
c[i+j-1]+=a[i]*b[j];
int lc=la+lb-1;
for(int i=1;i<=lc;i++)
{
c[i+1]+=c[i]/10;
c[i]%=10;
}
if (c[lc+1]>0) lc++;
for (int i=lc;i>=1;i--)
printf("%d",c[i]);
printf("\n");
}
by _XHY20180718_ @ 2022-10-27 19:50:42
@yaoyang007 你是不是没有去前导0...
by yaoyang007 @ 2022-10-27 19:55:23
@xiehuiying 加了一行 while (!c[lc]) lc--;之后变成too short了呜呜呜
by Anjunacoder @ 2022-10-27 19:57:39
@yaoyang007 lc需大于0
by _XHY20180718_ @ 2022-10-27 20:07:52
@yaoyang007 lc要大于0,至少为1。
比如 0*1=0
by yaoyang007 @ 2022-10-27 20:10:23
@xiehuiying 忽略0*0的了,已经AC,感谢大佬
by yaoyang007 @ 2022-10-27 20:10:33
@Anjunacoder 忽略0*0的了,已经AC,感谢大佬