class Solution {
public:
/**
* 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
*
* @param s string字符串 第一个整数
* @param t string字符串 第二个整数
* @return string字符串
*/
string solve(string s, string t) {
if (s == "0" || t == "0") {
return "0";
}
int lenS = s.size(), lenT = t.size();
vector<int>vecS(lenS, 0), vecT(lenT, 0);
vector<int>ret(lenS + lenT, 0);
for (int i = 0; i < lenS; i++) {
vecS[i] = s[i] -'0';
}
for (int i = 0; i < lenT; i++) {
vecT[i] = t[i] - '0';
}
for (int j = 0; j < lenT; j++) {
for (int i = 0; i < lenS; i++) {
ret[i + j + 1] += vecS[i] *vecT[j];
}
}
// 输出ret
for(auto n :ret) {
cout << n << endl;
}
int carry = 0;
for (int i = ret.size() - 1; i >= 0; i--) {
int sum = ret[i] + carry;
carry = sum / 10;
ret[i] = sum % 10;
}
for(auto n :ret) {
cout << n << endl;
}
// 消除ret前面的 0
int index = 0;
while(ret[index] == 0) {
index ++;
}
string strRet;
for(int i = index ; i < ret.size(); i++) {
strRet += to_string(ret[i]);
}
return strRet;
// write code here
}
};