Submission #949037

#TimeUsernameProblemLanguageResultExecution timeMemory
949037rainboy개구리들 (YDX13_frogs)C11
1 / 1
9 ms3920 KiB
#include <stdio.h> #define N 100000 #define M 10 #define K (N * M) #define INF 0x3f3f3f3f3f3f3f3fLL int main() { static char visited[K]; static int ll[K]; int n, m, c, a, b, r, s, k, l, h; long long d, lower, upper, x, y; scanf("%d%d%d%d%lld", &a, &n, &c, &m, &d); s = 1 * m + 1, k = 0, l = 0; while (!visited[s]) { visited[s] = 1; if (s % m == 0) l++; ll[k++] = l; b = s / m, r = s % m; b = (long long) b * a % n, r = (r + b) % m; s = b * m + r; } lower = 0, upper = INF; while (upper - lower > 1) { x = (lower + upper) / 2; y = x; for (h = 0; h + 1 < c; h++) y = (y / k) * l + ll[y % k]; if (x - y >= d) upper = x; else lower = x; } printf("%lld\n", upper); return 0; }

Compilation message (stderr)

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