Submission #479384

#TimeUsernameProblemLanguageResultExecution timeMemory
479384rainboyLun (COCI19_lun)C11
50 / 50
1 ms280 KiB
#include <stdio.h> #define N 100 int f(int d) { return d < 5 ? d * 2 : (d - 5) * 2 + 1; } int g(int d) { return d % 2 == 0 ? d / 2 : d / 2 + 5; } int main() { static char cc[N + 1]; int n, i, i_, d; scanf("%d%s", &n, cc); d = 0, i_ = -1; for (i = n - 1; i >= 0; i--) if (cc[i] != 'x') d = (d + ((n - i) % 2 == 0 ? f(cc[i] - '0') : cc[i] - '0')) % 10; else i_ = i; d = (10 - d) % 10; if ((n - i_) % 2 == 0) d = g(d); printf("%d\n", d); return 0; }

Compilation message (stderr)

lun.c: In function 'main':
lun.c:17:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |  scanf("%d%s", &n, cc);
      |  ^~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...