_Maverick_ @ 2023-12-02 19:13:50
#include<bits/stdc++.h>
using namespace std;
int a[20500]={0},b[20500]={0},c[40500]={0};
int main(){
string as,bs;
cin>>as>>bs;
int al=as.size(),bl=bs.size(),cl=al+bl;
for(int i=1;i<=al;i++) a[i]=as[al-i]-'0';
for(int i=1;i<=bl;i++) b[i]=bs[bl-i]-'0';
for(int i=1;i<=al;i++){
for(int j=1;j<=bl;j++){
c[i+j-1]+=a[i]*b[j];
c[i+j]+=c[i+j-1]/10;
c[i+j-1]%=10;
}
}
while(c[cl]==0&&cl>0) cl--;
string cs;
for(int i=cl;i>=1;i--) cs+=c[i]+'0';
cout<<cs;
return 0;
}
by GPUawa @ 2023-12-02 19:22:31
你得判断乘数中是不是有0
可以在乘法前用
if(atoi(as.c_str())==0 || atoi(as.c_str())==0) cout<<0;
判断乘数是否有一个为0
by GPUawa @ 2023-12-02 19:23:33
@dldl_____
by _Maverick_ @ 2023-12-02 19:26:15
@GPUawa 谢谢
by liruizhou_lihui @ 2023-12-02 20:02:34
建议学习一下python
by MrZombie_409 @ 2023-12-13 16:54:47
python只用一行就能解决(python没有高精的概念)