求助大犇们,这道题为什么RE??

P1303 A*B Problem

MChang @ 2019-07-30 11:14:05

include<iostream>

include<iomanip>

include<cstring>

using namespace std;

string gaocheng(string x, string y)

{

int i,j,l1,l2,q;

l1=x.size(),l2=y.size();

int l=l1+l2;

string result="";

int a[10001],b[10001],s[100001];

memset(a,0,sizeof(a));

memset(b,0,sizeof(b));

memset(s,0,sizeof(s));

for(i=0;i<l1;i++)

a[l1-i] = x[i] - '0';

for(i=0;i<l2;i++)

b[l2-i] = y[i] - '0';

for(i=0;i<=l1;i++)

{

    q=0;

    for(j=0;j<=l2;j++)

    {

        s[i+j-1]+=a[i]*b[j]+q;

        q=s[i+j-1]/10;

        s[i+j-1]%=10;

    }

    s[i+l2]=q;

}

while(s[l]==0&&l>1)l--;

for(i = l;i>0;i--)

result += char(s[i] + '0');

return result;

}

int main()

{

string x,y;

cin>>x>>y;

cout<<gaocheng(x,y);

return 0;

}


by team109 @ 2019-07-30 11:27:56

@zhaojinxi 谢谢大佬orz


上一页 |