This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <stdio.h>
#define D 9
int main() {
static int pp[D];
static long long ss[D];
int n, m, d, h, r, r_, c;
long long sum;
scanf("%d%d%d", &n, &m, &d);
if (n % m != 0 || d % 2 == 0 || d % 5 == 0) {
printf("NESIDALO\n");
return 0;
}
for (r = 0; r < d; r++) {
r_ = r, c = 0;
do
ss[r] += r_ * 10 / d, r_ = r_ * 10 % d, c++;
while (r_ != r);
ss[r] *= (m - 1) / c;
for (h = 0, r_ = r; h < (m - 1) % c; h++)
ss[r] += r_ * 10 / d, r_ = r_ * 10 % d;
ss[r] += (r_ * 10 + 1) / d, pp[r] = (r_ * 10 + 1) % d;
}
r = 0, c = 0, sum = 0;
do
sum += ss[r], r = pp[r], c++;
while (r != 0);
if (n / m % c != 0)
printf("NESIDALO\n");
else {
sum *= n / m / c;
printf("%lld\n", sum);
}
return 0;
}
Compilation message (stderr)
vienetai.c: In function 'main':
vienetai.c:11:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
11 | scanf("%d%d%d", &n, &m, &d);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |