HuangSiHan3116 @ 2024-07-18 22:38:38
特垃圾,有办法改吗?
#include<bits/stdc++.h>
using namespace std;
int main(){
long long int a,b;
cin>>a>>b;
printf("%lld",a*b);
return 0;
}
by jiangyelei @ 2024-07-23 16:38:17
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
const int q=1e4+4;
int main()
{
char a1[q],b1[q];
int a[q],b[q],c[q],lena,lenb,lenc,i,j,x;
memset(a,0,sizeof(a));
memset(b,0,sizeof(b));
memset(c,0,sizeof(c));
cin>>a1>>b1;
lena=strlen(a1);
lenb=strlen(b1);
for(i=0;i<=lena-1;i++)
a[lena-i]=a1[i]-48;
for(i=0;i<=lenb-1;i++)
b[lenb-i]=b1[i]-48;
for(i=1;i<=lena;i++)
{
x=0;
for(j=1;j<=lenb;j++)
{
c[i+j-1]=a[i]*b[j]+x+c[i+j-1];
x=c[i+j-1]/10;
c[i+j-1]%=10;
}
c[i+lenb]=x;
}
lenc=lena+lenb;
while (c[lenc]==0 && lenc>1)
lenc--;
for(i=lenc;i>=1;i--)
cout<<c[i];
cout<<'\n';
return 0;
}
//c++
by haewa @ 2024-08-14 15:57:07
最简单的是加法吧。乘法还要双重循环 @wangcaizsr
by wangcaizsr @ 2024-08-14 17:18:27
@haewa 我是说用高精度做简单,不是说这个是高精度里最简单的