QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#676959#7698. ISBN Conversionnew_game_plus_players#WA 0ms3584kbC++14942b2024-10-26 06:30:202024-10-26 06:30:20

Judging History

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

  • [2024-10-26 06:30:20]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3584kb
  • [2024-10-26 06:30:20]
  • 提交

answer

#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
bool solve() {
	string s;
	cin>>s;
	vector<int> h, v;
	for (int i=0; i<s.size(); i++) {
		if (s[i]=='-') {
			h.PB(i);
		} else {
			v.PB(s[i]=='X' ? 10 : s[i]-'0');
		}
		if (s[i]=='X' && i+1 < s.size()) return false;
	}
	if (h.size() > 3) return false;
	if (h.size()==3 && h[2] != s.size()-2) return false;
	if (v.size() != 10) return false;
	int sum = 0;
	for (int i=0; i<10; i++) {
		sum += (10-i) * v[i];
	}
	if (sum%11 != 0) return false;
	sum = 9 + 7 * 3 + 8;
	for (int i=0; i<9; i++) {
		sum += (3 - (i%2)*2) * v[i];
	}
	int cs = 10 - sum % 10;
	string t = "978-";
	t = t + s;
	t[t.size()-1] = '0' + cs;
	cout<<t<<endl;
	return true;
}

int main() {
	int Tn;
	cin>>Tn;
	while (Tn--) {
		if (!solve()) {
			puts("invalid");
		}
	}
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3576kb

input:

4
3-540-4258-02
039428013X
3-540-42580-2
0-14-028333-3

output:

invalid
978-0394280134
978-3-540-42580-9
invalid

result:

ok 4 lines

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3584kb

input:

25
----------
-----------
------------
-------------
XXXXXXXXXX
XXXXXXXXXXX
XXXXXXXXXXXX
XXXXXXXXXXXXX
---------X
----------X
-----------X
01234567890
012345678901
0123456789012
-0123456789-
0123456789-
-0123456789
01--23456789
012345678--9
0123456789--
--0123456789
98765432-1
987-654-321
87-645-32-...

output:

invalid
invalid
invalid
invalid
invalid
invalid
invalid
invalid
invalid
invalid
invalid
invalid
invalid
invalid
978--01234567896
978-01234567896
978--0123456786
978-01--23456786
978-012345678--6
978-0123456789-6
978---0123456786
invalid
invalid
invalid
invalid

result:

wrong answer 15th lines differ - expected: 'invalid', found: '978--01234567896'