AcWing 793. 高精度乘法
原题链接
简单
作者:
__43
,
2020-09-24 11:36:48
,
所有人可见
,
阅读 309
#include <iostream>
#include <vector>
using namespace std;
vector<int> c(vector<int>& v1, int c)
{
vector<int> v;
int x = 0;
for (int i = 0; i < v1.size() || x; ++i)
{
if (i < v1.size()) x += c * v1[i];
v.emplace_back(x % 10);
x = x / 10;
}
while (v.size() > 1 && v.back() == 0) v.pop_back();
return v;
}
int main(void)
{
string a;
int b;
vector<int> v, v1;
cin >> a >> b;
for (int i = a.size() - 1; i > -1; --i) v1.emplace_back(a[i] - '0');
v = c(v1, b);
for (int i = v.size() - 1; i > -1; --i) printf("%d", v[i]);
return 0;
}