Submission #112151

#TimeUsernameProblemLanguageResultExecution timeMemory
112151dolphingarlicLun (COCI19_lun)C++14
50 / 50
3 ms384 KiB
#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 timeMemoryGrader output
Fetching results...