为什么只有10分

P1303 A*B Problem

minkite @ 2018-10-04 20:22:53

#include<bits/stdc++.h>
using namespace std;
#define N 20000
char a1[N],b1[N];
int a[N],b[N],c[N],lena,lenb,lenc;

int main()
{
         scanf("%s",a1);
         scanf("%s",b1);
         lena=strlen(a1);
         lenb=strlen(b1);
         for(int i=0;i<lena;i++)
          a[lena-i]=a1[i]-'0';
          for(int i=0;i<lenb;i++)
            b[lenb-i]=b1[i]-'0';
             for(int i=1;i<=lena;i++)

                 int x=0;
                 for(int j=1;j<=lenb;j++)
                {   c[i+j-1]=a[i]*b[i]+x+c[i+j-1];
                   x=c[i+j-1]/10;
                   c[i+j-1]%=10;
                   }
                   c[i+lenb]=x;
                   }
                   int lenc=lena+lenb;
                   while(c[lenc]==0&&lenc>1)
                     lenc--;
                     for(int i=lenc;i>=1;i--)
                        cout<<c[i];

               return 0;
}

by minkite @ 2018-10-04 20:24:48

20分.


by durbin中将 @ 2018-10-04 20:32:34

不如python2```python a=input() b=input() print a*b


by minkite @ 2018-10-04 20:34:51

已过,谢谢


|