51 lines
1.2 KiB
C++
51 lines
1.2 KiB
C++
|
//#include <iostream>
|
||
|
//#include <vector>
|
||
|
//#include <string>
|
||
|
//
|
||
|
//using namespace std;
|
||
|
//
|
||
|
//string highPrecisionMultiply(const string& s1, const string& s2) {
|
||
|
// int la = s1.length();
|
||
|
// int lb = s2.length();
|
||
|
// vector<int> a(la, 0);
|
||
|
// vector<int> b(lb, 0);
|
||
|
// vector<int> c(la + lb, 0);
|
||
|
//
|
||
|
// for (int i = 0; i < la; i++) {
|
||
|
// a[la - i - 1] = s1[i] - '0'; // Reverse order
|
||
|
// }
|
||
|
// for (int i = 0; i < lb; i++) {
|
||
|
// b[lb - i - 1] = s2[i] - '0'; // Reverse order
|
||
|
// }
|
||
|
//
|
||
|
// for (int i = 0; i < la; i++) {
|
||
|
// for (int j = 0; j < lb; j++) {
|
||
|
// c[i + j] += a[i] * b[j];
|
||
|
// }
|
||
|
// }
|
||
|
//
|
||
|
// // Handle carry
|
||
|
// for (int i = 0; i < la + lb; i++) {
|
||
|
// if (c[i] >= 10) {
|
||
|
// c[i + 1] += c[i] / 10;
|
||
|
// c[i] %= 10;
|
||
|
// }
|
||
|
// }
|
||
|
//
|
||
|
// // Remove leading zeros
|
||
|
// int lc = la + lb;
|
||
|
// while (lc > 1 && c[lc - 1] == 0) lc--;
|
||
|
//
|
||
|
// string result;
|
||
|
// for (int i = lc - 1; i >= 0; i--) {
|
||
|
// result.push_back(c[i] + '0');
|
||
|
// }
|
||
|
//
|
||
|
// return result.empty() ? "0" : result;
|
||
|
//}
|
||
|
//
|
||
|
//int main() {
|
||
|
// cout << highPrecisionMultiply("50", "50") << endl; // Expected output: 2500
|
||
|
// return 0;
|
||
|
//}
|