QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#560723#6407. Classical A+B ProblemApteryxxWA 0ms3648kbC++201.0kb2024-09-12 17:31:552024-09-12 17:31:56

Judging History

你现在查看的是最新测评结果

  • [2024-09-12 17:31:56]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3648kb
  • [2024-09-12 17:31:55]
  • 提交

answer

#include <bits/stdc++.h>

#ifdef LOCAL
#include <debug.h>
#else
#define debug(...)
#define debug_arr(...)
#define debug_endl(...)
#endif

void solve() {
	std::string s;
	std::cin >> s;

	int n = s.length();

	std::vector<int> a(n);
	for (int i = 0; i < n; i++) {
		a[i] = s[n - i - 1] - '0';
	}

	for (int i = n - 1; i <= n; i++) {
		for (int j = 1; j <= 9; j++) {
			auto b = a;
			for (int k = 0; k < i; k++) {
				b[k] -= j;
			}
			for (int k = 0; k < n - 1; k++) {
				if (b[k] < 0) {
					b[k] += 10;
					b[k + 1]--;
				}
			}
			while (!b.empty() && b.back() == 0) {
				b.pop_back();
			}

			if (!b.empty() && b[0] > 0 && b == std::vector(b.size(), b[0])) {
				std::cout << std::string(b.size(), '0' + b[0]) << " " << std::string(i, '0' + j) << "\n";
				return;
			}
		}
	}
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
	std::cout.setf(std::ios::fixed);
	std::cout.precision(10);

	int t;
	std::cin >> t;

	while (t--) {
		solve();
		debug_endl(std::endl);
	}

	return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3648kb

input:

6
2
786
1332
89110
2333333
10000000000000000000000000001

output:

2 
9 777
999 333
222 88888
2222222 111111
2 9999999999999999999999999999

result:

wrong answer x + y != n (test case 1)