Submission #224942

#TimeUsernameProblemLanguageResultExecution timeMemory
224942VEGAnnLun (COCI19_lun)C++14
50 / 50
6 ms512 KiB
#include <bits/stdc++.h> #define all(x) x.begin(),x.end() using namespace std; int n, vl[10] = {0, 2, 4, 6, 8, 1, 3, 5, 7, 9}, loc; string s; bool ok(){ int sm = 0; for (int i = 1; i < n; i++) if (i & 1){ sm += vl[s[i] - '0']; } else { sm += s[i] - '0'; } return ((sm * 9) % 10) == (s[0] - '0'); } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cin >> n >> s; reverse(all(s)); loc = s.find('x'); for (int dg = 0; dg < 10; dg++) { s[loc] = char(dg + '0'); if (ok()){ cout << dg; return 0; } } return -1; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...