求助大佬,明明都过了测试点了还是3个WA和超时

P1303 A*B Problem

兀pai @ 2019-08-04 21:12:10

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
char m[200],n[200];
int a[200],b[200],c[200],lenn,lenm,j,i,len,x;
int main(){
    gets(m);
    gets(n);
    lenm=strlen(m);
    lenn=strlen(n);
    for(i=0;i<lenm;i++)  a[lenm-i]=m[i]-48;
    for(i=0;i<lenn;i++)  b[lenn-i]=n[i]-48;
    for(i=1;i<=lenm;i++){
        x=0;
        for(j=1;j<=lenn;j++){
            c[i+j-1]+=a[i]*b[j]+x;
            x=c[i+j-1]/10;
            c[i+j-1]%=10;
        }
        c[i+lenn]=x;
    }
    len=lenn+lenm;
    while(len>1&&c[len]==0)  len--;
    for(i=len;i>0;i--)  cout<<c[i];
    return 0;
} 

by ud2_ @ 2019-08-04 21:17:44

不要用 gets


by infinities @ 2019-08-04 21:18:47

直接用python3,另外,数组要开2001


by infinities @ 2019-08-04 21:21:01

@兀pai


by 兀pai @ 2019-08-04 21:47:10

好的,解决了,谢谢各位


|