#include <iostream> #include <cmath> #include <vector> using namespace std; int main(){ string a,b; cin>>a>>b; vector<int> x,y; for(int i = a.size()-1;i>=0;i--){ x.push_back(a[i]-'0'); } for(int i = b.size()-1;i>=0;i--){ y.push_back(b[i]-'0'); } vector<int> sum(x.size()+y.size()+10,0); for(int i = 0;i<x.size();i++){ for(int j = 0;j<y.size();j++){ sum[i+j] += x[i]*y[j]; } } int j = 0; for(int i = 0;i<sum.size() || j;i++){ j += sum[i]; sum[i] = j%10; j /= 10; } while(sum.size()>1 && sum.back()==0){ sum.pop_back(); } for(int i = sum.size()-1;i>=0;i--){ cout<<sum[i]; } return 0; }
标签:高精度,int,sum,back,--,size From: https://www.cnblogs.com/wangyihang-xh/p/18225216