AcWing 793. 高精度乘法
原题链接
简单
#include<bits/stdc++.h>
using namespace std;
vector<int> mul(vector<int> &a,int b)
{
vector<int> c;
int t = 0;
for(int i = 0; i < a.size() || t; ++i)
{
if(i < a.size()) t += a[i] * b;
c.push_back(t % 10);
t /= 10;
}
return c;
}
int main()
{
string s1; cin >> s1;
int b; cin >> b;
vector<int> a;
for(int i = 0; i < s1.size(); ++i) a.push_back(s1[i]-'0');
reverse(a.begin(),a.end());
vector<int> c = mul(a,b);
reverse(c.begin(),c.end());
for(int i = 0; i < c.size(); ++i) cout << c[i];
return 0;
}