洛谷评测机结果与在线 IDE 不一致
  • 板块学术版
  • 楼主YMnRb
  • 当前回复4
  • 已保存回复4
  • 发布时间2023/12/3 19:43
  • 上次更新2023/12/3 21:56:18
查看原帖
洛谷评测机结果与在线 IDE 不一致
812740
YMnRb楼主2023/12/3 19:43

洛谷评测机结果与在线 IDE 不一致

图 1 P1601 R138093654 #3 测试点 RE

图 2 洛谷在线 IDE 使用相同代码及数据运行结果正确

附 源代码 求调

#include <iostream>
#include <algorithm>
using namespace std;

struct big_int {
	int num[1024], l;
} a, b;
big_int operator+(big_int a, const big_int& b) {
	for (int i = 1023; i >= a.l || i >= b.l; --i) {
		a.num[i] += b.num[i];
		a.num[i - 1] += a.num[i] / 10;
		a.num[i] %= 10;
	}
	return a;
} 
void read(big_int& a) {
	char c;
	int i = 0;
	while (a.num[i++] = 0, i != 1024);
	while (!(((c = getchar()) & 48) && c < 58)); a.num[--i] = c & 15; 
	while (((c = getchar()) & 48) && c < 58) a.num[--i] = c & 15; 
	a.l = i;
	while (swap(a.num[i], a.num[(a.l | 1024) - i - 1]), ++i < (a.l | 1024) >> 1);
}
void print(const big_int& a) {
	int i = 0;
	while (!a.num[i++]);
	--i;
	while (printf("%d", a.num[i++]), i != 1024);
}
int main() { read(a), read(b), print(a + b); return 0; }
2023/12/3 19:43
加载中...