Submission #197041

# Submission time Handle Problem Language Result Execution time Memory
197041 2020-01-18T09:30:47 Z Vlatko Lun (COCI19_lun) C++14
50 / 50
3 ms 504 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;



int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; ++i) {
		char ch;
		cin >> ch;
		a[i] = ch == 'x' ? -1 : ch-'0';
	}
	int ans = 10;
	for (int x = 0; x <= 9; ++x) {
		int sum = 0;
		for (int i = n-2, j = 1; i >= 0; --i, j = 1-j) {
			int d = a[i] == -1 ? x : a[i];
			if (j) d *= 2;
			if (d >= 10) d = d/10 + d%10;
			sum += d;
		}
		sum *= 9;
		sum %= 10;
		if (sum == (a[n-1] == -1 ? x : a[n-1])) {
			ans = x;
			break;
		}
	}
	cout << ans << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 504 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 3 ms 380 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct