__Function__ @ 2024-07-16 21:11:24
xdm,众所周知,洛谷的相关工作人员会出一些超过整形范围的题,我为了装逼保险,提交了高精度代码,为啥50分?
下面附上我的代码
#include <bits/stdc++.h>
using namespace std;
int a[100], b[100], c[100];
int main() {
string s1, s2;
cin >> s1 >> s2;
int la = s1.size(), i , lb = s2.size();
for (i = 0; i < la; ++i)
a[i] = s1[la - 1 - i] - '0';
for (i = 0; i < lb; ++i)
b[i] = s2[lb - 1 - i] - '0';
int lc = max(la, lb);
for (i = 0; i < lc; ++i) {
c[i] = c[i] + a[i] + b[i];
if (c[i] > 9) {
c[i] -= 10;
c[i + 1]++;
}
}
if (c[lc]) ++lc;
while (lc > 1 && c[lc - 1] == 0)
lc--;
for (i = lc - 1; i >= 0; --i)
cout << c[i];
return 0;
}
PS:虽然我会这道题,但是高精为啥会错,还是想请教一下大佬。 又PS:我们团队的比赛是乐多赛制,少了5分QAQ
by yukimianyan @ 2024-07-16 21:12:31
负数
by liangbowen @ 2024-07-16 21:12:37
负数 :)
by __Function__ @ 2024-07-16 21:20:36
@yukimianyan @liangbowen 懂了,谢谢。
by zxckhj114514 @ 2024-07-30 14:33:32
负数