文章
79
粉丝
221
获赞
46
访问
198.4k
#include <iostream>
#include <string>
using namespace std;
string SP(string s1, string s2) {
int i = s1.size() - 1, j = s2.size() - 1;
int k = 0;
string res = "";
while (i >= 0 && j >= 0) {
res = char((s1[i] - '0' + s2[j] - '0' + k) % 10 + '0') + res;
k = (s1[i] - '0' + s2[j] - '0' + k) / 10;
i--, j--;
}
while (i >= 0) {
res = char((s1[i] - '0' + k) % 10 + '0') + res;
k = (s1[i] - '0' + k) / 10;
i--;
}
while (j >= 0) {
res = char((s2[j] - '0' + k) % 10 + '0') + res;
k = (s2[j] - '0' + k) / 10;
j--;
}
if (k)
res = char(k + '0') + res;
return res;
}
string SM(string s1, int a) {
int k = 0;
string res = "";
for (int i = s1.size() - 1; i >= 0; i--) {
res = char(((s1[i] - '0') * a + k) % 10 + '0') + res;
k = ((s1[i] - '0') * a + k) / 10;
}
if (k)
res = char(k + '0') + res;
return res;
}
int main() {
int n;
cin >> n;
string res = "0", temp = "1";
for (int i ...
登录后发布评论
暂无评论,来抢沙发