QLUzongyuxing @ 2022-02-13 17:22:59
#include<bits/stdc++.h>
using namespace std;
string s1,s2;
int a[2000],b[2000],c[2000],ls1,ls2,f;
int main()
{
cin>>s1>>s2;
ls1=s1.size();
ls2=s2.size();
for(int i=0;i<ls1;i++) a[ls1-i]=s1[i]-'0';
for(int j=0;j<ls2;j++) b[ls2-j]=s2[j]-'0';
f=ls1+ls2;
for(int i=1;i<=ls1;i++){
for(int j=1;j<=ls2;j++){
c[i+j-1]+=a[i]*b[j];
c[i+j]+=c[i+j-1]/10;
c[i+j-1]=c[i+j-1]%10;
}
}
while(c[f]==0&&f>1) f--;
for(int i=f;i>0;i--){
cout<<c[i];
}
}
by Mr_Terminator @ 2022-02-13 17:27:52
乘积位数请开到4000位
by LaDeX @ 2022-02-13 17:29:35
楼上正解;
a数组2000+b数组2000>c数组2000
by QLUzongyuxing @ 2022-02-13 17:29:55
@幽灵2 过了,谢谢!!!
by QLUzongyuxing @ 2022-02-13 17:30:47
@GIAOchen 谢谢!!
by bailanxiaozi @ 2022-03-24 00:02:23
@GIAOchen 想问一下为什么开到4000就可以了
by my_stream @ 2022-03-24 11:04:35
@bailanxiaozi 最后一组测试数据很长的
by LaDeX @ 2022-03-24 17:13:27
@bailanxiaozi 因为
by bailanxiaozi @ 2022-03-25 21:06:48
谢谢!