# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
147254 | 2019-08-28T14:00:11 Z | ipaljak | Lun (COCI19_lun) | C++14 | 3 ms | 376 KB |
#include <bits/stdc++.h> using namespace std; #define TRACE(x) cerr << #x << " " << x << endl #define FOR(i, a, b) for (int i = (a); i < int(b); ++i) #define REP(i, n) FOR(i, 0, n) #define _ << " " << typedef long long llint; const int MOD = 1e9 + 7; const int MAXN = 105; int n; char s[MAXN]; bool check(int x) { int sum = 0; for (int i = 1; i < n; ++i) { int d = (s[n - i - 1] - '0'); if (s[n - i - 1] == 'x') d = x; if (i % 2 == 1) d *= 2; if (d >= 10) d = 1 + (d % 10); sum += d; } sum *= 9; sum %= 10; int val = s[n - 1] - '0'; if (s[n - 1] == 'x') val = x; return sum == val; } int main(void) { scanf("%d", &n); scanf("%s", s); for (int x = 0; x < 10; ++x) { if (s[0] == 'x' && x == 0) continue; if (check(x)) { printf("%d\n", x); break; } } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 256 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 | 256 KB | Output is correct |
8 | Correct | 2 ms | 256 KB | Output is correct |
9 | Correct | 2 ms | 376 KB | Output is correct |
10 | Correct | 2 ms | 256 KB | Output is correct |