Submission #949037

# Submission time Handle Problem Language Result Execution time Memory
949037 2024-03-18T20:33:07 Z rainboy 개구리들 (YDX13_frogs) C
1 / 1
9 ms 3920 KB
#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

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 time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 2 ms 856 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 428 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 344 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 1 ms 344 KB Output is correct
37 Correct 1 ms 344 KB Output is correct
38 Correct 0 ms 344 KB Output is correct
39 Correct 1 ms 344 KB Output is correct
40 Correct 0 ms 348 KB Output is correct
41 Correct 1 ms 348 KB Output is correct
42 Correct 1 ms 348 KB Output is correct
43 Correct 1 ms 360 KB Output is correct
44 Correct 0 ms 432 KB Output is correct
45 Correct 1 ms 348 KB Output is correct
46 Correct 0 ms 348 KB Output is correct
47 Correct 1 ms 348 KB Output is correct
48 Correct 1 ms 348 KB Output is correct
49 Correct 1 ms 348 KB Output is correct
50 Correct 1 ms 604 KB Output is correct
51 Correct 0 ms 348 KB Output is correct
52 Correct 1 ms 600 KB Output is correct
53 Correct 1 ms 348 KB Output is correct
54 Correct 0 ms 348 KB Output is correct
55 Correct 9 ms 3920 KB Output is correct
56 Correct 2 ms 792 KB Output is correct
57 Correct 1 ms 348 KB Output is correct
58 Correct 0 ms 348 KB Output is correct
59 Correct 3 ms 944 KB Output is correct
60 Correct 6 ms 1628 KB Output is correct
61 Correct 0 ms 348 KB Output is correct
62 Correct 2 ms 856 KB Output is correct
63 Correct 2 ms 604 KB Output is correct
64 Correct 0 ms 348 KB Output is correct
65 Correct 2 ms 860 KB Output is correct
66 Correct 1 ms 856 KB Output is correct
67 Correct 1 ms 856 KB Output is correct
68 Correct 1 ms 1372 KB Output is correct
69 Correct 0 ms 348 KB Output is correct