# 高精度乘法()-其他

## 高精度乘法()

#include <iostream>
#include <vector>
using namespace std;
vector<int> a, b, c;

void mul () {
int m = a.size(), n = b.size();
c = vector<int> (m + n);
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, t = 0; i < c.size(); i++) {
t += c[i];
c[i] = t % 10;
t /= 10;
}

while (c.size() > 1 && c.back() == 0) c.pop_back();
}

int main() {
string x, y;
cin >> x >> y;

for (int i = x.size() - 1; i >= 0; i--) a.push_back(x[i] - '0');
for (int i = y.size() - 1; i >= 0; i--) b.push_back(y[i] - '0');

mul();

for (int i = c.size() - 1; i >= 0; i--) cout << c[i];
return 0;
}
————————

#include <iostream>
#include <vector>
using namespace std;
vector<int> a, b, c;

void mul () {
int m = a.size(), n = b.size();
c = vector<int> (m + n);
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, t = 0; i < c.size(); i++) {
t += c[i];
c[i] = t % 10;
t /= 10;
}

while (c.size() > 1 && c.back() == 0) c.pop_back();
}

int main() {
string x, y;
cin >> x >> y;

for (int i = x.size() - 1; i >= 0; i--) a.push_back(x[i] - '0');
for (int i = y.size() - 1; i >= 0; i--) b.push_back(y[i] - '0');

mul();

for (int i = c.size() - 1; i >= 0; i--) cout << c[i];
return 0;
}