QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#114254#6407. Classical A+B ProblemOepelingWA 2ms3464kbC++141.1kb2023-06-21 19:28:112023-06-21 19:28:13

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-06-21 19:28:13]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3464kb
  • [2023-06-21 19:28:11]
  • 提交

answer

#include <iostream>
#include <vector>

using namespace std;

bool Check(vector<int> v, int a, int b) {
	int r = 0;
	int len_a = 0, len_b = 0;
	bool stopped = false;
	for (int i = 0; i < v.size(); i++) {
		int aux = r + a + b;
		if (aux % 10 == v[i] && !stopped) {
			r = aux / 10;
			len_a++;
			len_b++;
		} else {
			aux = r + b;
			if (aux % 10 == v[i]) {
				len_b++;
				r = aux / 10;
				stopped = true;
			} else if (r == v[i] && i == v.size() - 1) {
				r = 0;
				continue;
			} else {
				return false;
			}
		}
	}

	if (r != 0) {
		return false;
	}

	cout << string(len_a, a + '0') << " " << string(len_b, b + '0') << '\n';
	return true;
}

void Solve() {
	string n; cin >> n;
	vector<int> v;

	for (int i = n.size() - 1; i >= 0; i--) {
		v.push_back(n[i] - '0');
	}

	for (int i = 1; i < 10; i++) {
		int j = (10 + v[0] - i) % 10;
		if (j == 0) { continue; }
		if (Check(v, i, j)) {
			break;
		}
	}
}

int main() {
	int t; cin >> t;
	for (int i = 0; i < t; i++) {
		Solve();
	}
}

/*
6
2
786
1332
89110
2333333
10000000000000000000000000001

*/

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3464kb

input:

6
2
786
1332
89110
2333333
10000000000000000000000000001

output:

1 1
9 777
333 999
222 88888
111111 2222222
2 9999999999999999999999999999

result:

ok ok (6 test cases)

Test #2:

score: -100
Wrong Answer
time: 2ms
memory: 3452kb

input:

100
854
77777777781111111111111111110
44444450
11111111111111333
2310
5
333333333333333333333343332
888999
10
11113333
335
77779
88888888888888888888889111111111111111111110
55555555555555777777
72222222222222222222221
666
5777
1111555555
444444444544444444443
88888888888891111111111110
673332
97
77...

output:

77 777
3333333333333333333 77777777777777777777777777777
6 44444444
222 11111111111111111
88 2222
1 4
9999 333333333333333333333333333
111 888888
2222 11111111
2 333
2 77777
222222222222222222222 88888888888888888888888888888888888888888888
222222 55555555555555555555
5555555555555555555555 66666666...

result:

wrong answer Token parameter [name=x] equals to "2222", doesn't correspond to pattern "[1-9]{1,2}" (test case 9)