#C08L02P02. C08.L02.高精度乘法.模板.高精度乘法(高精乘高精)
C08.L02.高精度乘法.模板.高精度乘法(高精乘高精)
题目描述
贝贝是学校信息学编程小组的学生,一天,他的数学老师碰到这样一个问题:他想求两个很长的数的乘积,但用普通的计算器无法完成计算,于是他请编程班的贝贝帮忙设计一个“超级计算器”,解决他所遇到的问题。
请你编一程序,帮贝贝解决这个问题。
输入格式
两行,分别是两个在10^100 以内的然数。
输出格式
两数相乘的结果。
样例
578474357954668
12435124571
7193400702295541350947428
程序填空
#include<bits/stdc++.h>
using namespace std;
int d[1000];
int main()
{
string a,b,ans;
cin>>a>>b;
int len_a,len_b;
len_a=a.size();
len_b=b.size();
int t1,t2;
int i,j,ii,jj;
char c;
for(i=0,ii=len_a-1;ii>=0;ii--,i++)
{
t1 = 填空(1) ;
for(j=0,jj=len_b-1;jj>=0;jj--,j++)
{
t2 = 填空(2) ;
d[i+j] += 填空(3) ;
}
}
for(i=0;i<=len_a+len_b-2||d[i]>0;i++)
{
d[i+1] += 填空(4);
d[i] 填空(5);
c = '0' + d[i];
ans = 填空(6) ;
}
while( 填空(7) &&ans[0]=='0')
ans.erase(0,1);
cout<<ans;
return 0;
}
填空(1):{{ input(1) }}
填空(2):{{ input(2) }}
填空(3):{{ input(3) }}
填空(4):{{ input(4) }}
填空(5):{{ input(5) }}
填空(6):{{ input(6) }}
填空(7):{{ input(7) }}
相关
在以下作业中: