#include<iostream>
#include<string>
#include<vector>
using namespace std;
vector<int> A,B;
vector<int> mul(vector<int> A, vector<int> B)
{
vector<int> C(A.size()+B.size()+3, 0);
//对位相乘
for(int i = 0; i < A.size(); i ++)
for(int j = 0; j < B.size(); j ++)
C[i+j] += A[i]*B[j]; //+=
//进位
for(int i = 0; i < C.size(); i ++)
{
C[i+1] += C[i]/10;
C[i] %= 10;
}
//除去前导零
while(C.size()>1 && C.back() == 0)
C.pop_back();
return C;
}
int main()
{
string a,b;
cin >> a >> b;
for(int i = a.size()-1; i >= 0; i--)
A.push_back(a[i]-'0');
for(int i = b.size()-1; i >= 0; i--)
B.push_back(b[i]-'0');
vector<int> C = mul(A, B);
for(int i = C.size()-1; i >= 0; i--)
cout << C[i];
return 0;
}
来自站内大佬的图: