题……解?(魔怔
2023-08-20 17:03:35
发布于:浙江
5阅读
0回复
0点赞
#include <bits/stdc++.h>
#define c char
const int z = -0xffffffff - 1;
const std::string on = "1";
class _int {
public:
std::string n;
std::string O(std::string a, std::string b) {
int carry = 0, i = a.size() - 1, j = b.size() - 1;
std::string result;
while (i >= 0 || j >= 0 || carry) {
int digit1 = (i >= 0) ? (a[i] - '0') : 0;
int digit2 = (j >= 0) ? (b[j] - '0') : 0;
int sum = digit1 + digit2 + carry;
carry = sum / 10;
sum %= 10;
result += (sum + '0');
if (i >= 0) i--;
if (j >= 0) j--;
}
reverse(result.begin(), result.end());
return result;
}
std::string _P(std::string a, std::string b) {
std::string product;
for (int i = 0; i < a.size(); i++) {
for (int j = 0; j < b.size(); j++) {
int digit1 = a[i] - '0';
int digit2 = b[j] - '0';
int prod = digit1 * digit2;
product += (prod + '0');
}
}
return product;
}
};
int main() {
_int a, b;
std::cin >> a.n >> b.n;
std::string sum_result = a._P(a.O(a.n, b.n) ,on);
std::cout << sum_result;
return 0;
}
全部评论 1
讲究的就是一个让人看不懂(doge
2023-08-20 来自 浙江
0
有帮助,赞一个