# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
112151 |
2019-05-17T15:49:29 Z |
dolphingarlic |
Lun (COCI19_lun) |
C++14 |
|
3 ms |
384 KB |
#include <bits/stdc++.h>
#define FOR(i, x, y) for (ll i = x; i < y; i++)
#pragma GCC optimize("O3")
typedef long long ll;
using namespace std;
int dbl[10] = {0, 2, 4, 6, 8, 1, 3, 5, 7, 9};
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
int tot = 0;
bool needs_double = false;
FOR(i, 0, n - 1) {
char x;
cin >> x;
if (x == 'x') {
needs_double = !((n - i) & 1);
} else {
tot += (!((n - i) & 1) ? dbl[x - '0'] : (x - '0'));
}
}
char x;
cin >> x;
if (x == 'x') {
cout << (tot * 9) % 10 << '\n';
} else {
if (needs_double) {
FOR(i, 0, 10) {
if ((tot + dbl[i]) * 9 % 10 == (x - '0')) {
cout << i << '\n';
break;
}
}
} else {
FOR(i, 0, 10) {
if ((tot + i) * 9 % 10 == (x - '0')) {
cout << i << '\n';
break;
}
}
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
256 KB |
Output is correct |
8 |
Correct |
2 ms |
384 KB |
Output is correct |
9 |
Correct |
3 ms |
384 KB |
Output is correct |
10 |
Correct |
2 ms |
256 KB |
Output is correct |