Lily95 @ 2023-03-24 10:58:26
#include<iostream>
#include<vector>
#include<string>
using namespace std;
string a, b;
vector<int> mul(vector<int> A, vector<int> B)
{
int num = a.size() + b.size() - 1;
vector<int> C(num+1);
for (int i = 0; i < num; i++)
{
for (int j = 0; j <= i; j++)
{
C[i] += A[j] * B[i - j];
}
if (C[i] >= 10)
{
C[i + 1] += C[i] / 10;
C[i] %= 10;
}
}
while (C.back() == 0)
C.pop_back();
return C;
}
int main()
{
cin >> a;
cin >> b;
vector<int> A;
vector<int> B;
for (int i = a.size() - 1; i--; i >= 0)
A.push_back(a[i]-'0');
for (int i = b.size() - 1; i--; i >= 0)
B.push_back(b[i]-'0');
for (int i = A.size(); i < a.size() + b.size() - 1; i++)
A.push_back(0);
for (int i = B.size(); i < a.size() + b.size() - 1; i++)
B.push_back(0);
auto C = mul(A, B);
for (int i = C.size() - 1; i--; i >= 0)
cout << C[i];
return 0;
}