ASOP @ 2017-05-17 20:58:30
#include<iostream>
#include<string>
using namespace std;
int main()
{
string as,bs,ts;
int a[100001]={0},b[100001]={0},c[100001]={0},la,lb,lc;
cin>>as>>bs;
la=as.size();lb=bs.size();
for(int i=1;i<=la;i++)
a[i]=as[la-i]-'0';
for(int i=1;i<=lb;i++)
b[i]=bs[lb-i]-'0';
for(int i=1;i<=la;i++)
for(int j=1;i<=lb;j++)
c[i+j-1]+=a[i]*b[j];
lc=la+lb-1;
for(int i=1;i<=lc;i++)
if(c[i]>9){c[i+1]+=c[i]/10;c[i]%=10;}
while(c[lc]) lc++;
for(int i=lc-1;i>=1;i--) cout<<c[i];
return 0;
}
by 户山香澄 @ 2017-05-21 16:09:09
··· for(int i=1;i<=la;i++)
a[i]=as[la-i]-'0';
··· 应该改成
···
for (int i=1;i<=la;i++)
a[i]=as[la-i+1]-'0';
bs的同理