Submission #147254

#TimeUsernameProblemLanguageResultExecution timeMemory
147254ipaljakLun (COCI19_lun)C++14
50 / 50
3 ms376 KiB
#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 (stderr)

lun.cpp: In function 'int main()':
lun.cpp:34:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &n);
   ~~~~~^~~~~~~~~~
lun.cpp:35:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%s", s);
   ~~~~~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...