er56kksk @ 2017-07-01 10:43:29
#include<cstdio>
using namespace std;
const int maxN=2020;
int a[maxN+1],b[maxN+1],c[maxN+1];
void read(int []),write(int[]),multi(int [],int []);
int main(){
read(a);
read(b);
multi(a,b);
write(c);
return 0;
}
void read(int a[]) {
char ch=getchar();
int len=0;
while(ch<48||ch>57) ch=getchar();
while(ch>47&&ch<58) {
a[len++]=ch-48;
ch=getchar();
}
for(int i=maxN; i>=0; i--,len--)
if(len>0) a[i]=a[len-1];
else a[i]=0;
}
void multi(int a[],int b[]){
for(int i=maxN;i>=maxN/2;i--){
int k=0,t=i;
for(int j=maxN;j>maxN/2;j--){
c[t]+=a[i]*b[j]+k;
k=c[t]/10;
c[t]%=10;
t--;
}
c[t--]=k;
}
}
void write(int c[]) {
int i=0;
while(i<maxN&&c[i]==0) i++;
while(i<=maxN) printf("%d",c[i++]);
printf("\n");
}
by lingfly @ 2017-08-01 17:38:15
数组开小了