Submission #768805

# Submission time Handle Problem Language Result Execution time Memory
768805 2023-06-28T16:24:45 Z rainboy Nice sequence (IZhO18_sequence) C
100 / 100
306 ms 29636 KB
#include <stdio.h>

#define N	200000
#define M	200000

int gcd(int a, int b) {
	return b == 0 ? a : gcd(b, a % b);
}

int main() {
	int t;

	scanf("%d", &t);
	while (t--) {
		static int pp[N + M];
		int n, m, d, n_, i, p;

		scanf("%d%d", &n, &m), d = gcd(n, m), n_ = m + n - d;
		i = n_, p = 0;
		while (1) {
			i = i >= n ? i - n : i + m;
			if (i == n_)
				break;
			pp[i] = p++;
		}
		for (i = 0; i < n_; i += d)
			pp[i] *= d;
		for (i = 0; i < n_; i++)
			pp[i] = pp[i - i % d] + i % d;
		printf("%d\n", n_ - 1);
		for (i = 1; i < n_; i++)
			printf("%d ", pp[i] - pp[i - 1]);
		printf("\n");
	}
	return 0;
}

Compilation message

sequence.c: In function 'main':
sequence.c:13:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |  scanf("%d", &t);
      |  ^~~~~~~~~~~~~~~
sequence.c:18:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |   scanf("%d%d", &n, &m), d = gcd(n, m), n_ = m + n - d;
      |   ^~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Ok
2 Correct 0 ms 212 KB Ok
3 Correct 0 ms 296 KB Ok
4 Correct 1 ms 212 KB Ok
5 Correct 0 ms 212 KB Ok
6 Correct 0 ms 212 KB Ok
7 Correct 0 ms 212 KB Ok
8 Correct 0 ms 292 KB Ok
9 Correct 1 ms 212 KB Ok
10 Correct 1 ms 212 KB Ok
11 Correct 0 ms 292 KB Ok
12 Correct 1 ms 212 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Ok
2 Correct 0 ms 212 KB Ok
3 Correct 0 ms 212 KB Ok
4 Correct 0 ms 212 KB Ok
5 Correct 1 ms 212 KB Ok
6 Correct 2 ms 300 KB Ok
7 Correct 7 ms 552 KB Ok
8 Correct 3 ms 468 KB Ok
9 Correct 7 ms 596 KB Ok
10 Correct 4 ms 468 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Ok
2 Correct 0 ms 212 KB Ok
3 Correct 0 ms 212 KB Ok
4 Correct 0 ms 212 KB Ok
5 Correct 0 ms 212 KB Ok
6 Correct 0 ms 212 KB Ok
7 Correct 1 ms 292 KB Ok
8 Correct 0 ms 296 KB Ok
9 Correct 0 ms 212 KB Ok
10 Correct 0 ms 212 KB Ok
11 Correct 0 ms 212 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Ok
2 Correct 0 ms 212 KB Ok
3 Correct 1 ms 212 KB Ok
4 Correct 0 ms 212 KB Ok
5 Correct 0 ms 212 KB Ok
6 Correct 53 ms 3660 KB Ok
7 Correct 46 ms 3072 KB Ok
8 Correct 89 ms 5068 KB Ok
9 Correct 73 ms 5564 KB Ok
10 Correct 40 ms 2188 KB Ok
11 Correct 66 ms 4568 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Ok
2 Correct 0 ms 212 KB Ok
3 Correct 0 ms 296 KB Ok
4 Correct 1 ms 212 KB Ok
5 Correct 0 ms 212 KB Ok
6 Correct 0 ms 212 KB Ok
7 Correct 0 ms 212 KB Ok
8 Correct 0 ms 292 KB Ok
9 Correct 1 ms 212 KB Ok
10 Correct 1 ms 212 KB Ok
11 Correct 0 ms 292 KB Ok
12 Correct 1 ms 212 KB Ok
13 Correct 1 ms 212 KB Ok
14 Correct 0 ms 212 KB Ok
15 Correct 0 ms 212 KB Ok
16 Correct 0 ms 212 KB Ok
17 Correct 0 ms 212 KB Ok
18 Correct 0 ms 212 KB Ok
19 Correct 1 ms 292 KB Ok
20 Correct 0 ms 296 KB Ok
21 Correct 0 ms 212 KB Ok
22 Correct 0 ms 212 KB Ok
23 Correct 0 ms 212 KB Ok
24 Correct 2 ms 340 KB Ok
25 Correct 1 ms 340 KB Ok
26 Correct 2 ms 340 KB Ok
27 Correct 1 ms 340 KB Ok
28 Correct 1 ms 292 KB Ok
29 Correct 2 ms 212 KB Ok
30 Correct 1 ms 212 KB Ok
31 Correct 2 ms 296 KB Ok
32 Correct 2 ms 292 KB Ok
33 Correct 1 ms 340 KB Ok
34 Correct 3 ms 340 KB Ok
35 Correct 3 ms 468 KB Ok
36 Correct 3 ms 340 KB Ok
37 Correct 3 ms 428 KB Ok
38 Correct 3 ms 340 KB Ok
39 Correct 3 ms 340 KB Ok
40 Correct 3 ms 340 KB Ok
41 Correct 3 ms 340 KB Ok
42 Correct 3 ms 340 KB Ok
43 Correct 3 ms 340 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Ok
2 Correct 0 ms 212 KB Ok
3 Correct 0 ms 296 KB Ok
4 Correct 1 ms 212 KB Ok
5 Correct 0 ms 212 KB Ok
6 Correct 0 ms 212 KB Ok
7 Correct 0 ms 212 KB Ok
8 Correct 0 ms 292 KB Ok
9 Correct 1 ms 212 KB Ok
10 Correct 1 ms 212 KB Ok
11 Correct 0 ms 292 KB Ok
12 Correct 1 ms 212 KB Ok
13 Correct 0 ms 212 KB Ok
14 Correct 0 ms 212 KB Ok
15 Correct 0 ms 212 KB Ok
16 Correct 0 ms 212 KB Ok
17 Correct 1 ms 212 KB Ok
18 Correct 2 ms 300 KB Ok
19 Correct 7 ms 552 KB Ok
20 Correct 3 ms 468 KB Ok
21 Correct 7 ms 596 KB Ok
22 Correct 4 ms 468 KB Ok
23 Correct 1 ms 212 KB Ok
24 Correct 0 ms 212 KB Ok
25 Correct 0 ms 212 KB Ok
26 Correct 0 ms 212 KB Ok
27 Correct 0 ms 212 KB Ok
28 Correct 0 ms 212 KB Ok
29 Correct 1 ms 292 KB Ok
30 Correct 0 ms 296 KB Ok
31 Correct 0 ms 212 KB Ok
32 Correct 0 ms 212 KB Ok
33 Correct 0 ms 212 KB Ok
34 Correct 2 ms 340 KB Ok
35 Correct 1 ms 340 KB Ok
36 Correct 2 ms 340 KB Ok
37 Correct 1 ms 340 KB Ok
38 Correct 1 ms 292 KB Ok
39 Correct 2 ms 212 KB Ok
40 Correct 1 ms 212 KB Ok
41 Correct 2 ms 296 KB Ok
42 Correct 2 ms 292 KB Ok
43 Correct 1 ms 340 KB Ok
44 Correct 3 ms 340 KB Ok
45 Correct 3 ms 468 KB Ok
46 Correct 3 ms 340 KB Ok
47 Correct 3 ms 428 KB Ok
48 Correct 3 ms 340 KB Ok
49 Correct 3 ms 340 KB Ok
50 Correct 3 ms 340 KB Ok
51 Correct 3 ms 340 KB Ok
52 Correct 3 ms 340 KB Ok
53 Correct 3 ms 340 KB Ok
54 Correct 43 ms 1984 KB Ok
55 Correct 62 ms 2096 KB Ok
56 Correct 48 ms 2080 KB Ok
57 Correct 38 ms 1764 KB Ok
58 Correct 43 ms 2032 KB Ok
59 Correct 42 ms 1888 KB Ok
60 Correct 36 ms 1700 KB Ok
61 Correct 37 ms 1752 KB Ok
62 Correct 53 ms 2128 KB Ok
63 Correct 40 ms 1768 KB Ok
64 Correct 47 ms 2096 KB Ok
65 Correct 46 ms 2060 KB Ok
66 Correct 42 ms 1876 KB Ok
67 Correct 36 ms 1740 KB Ok
68 Correct 44 ms 1936 KB Ok
69 Correct 76 ms 5916 KB Ok
70 Correct 77 ms 7364 KB Ok
71 Correct 94 ms 5140 KB Ok
72 Correct 70 ms 6300 KB Ok
73 Correct 73 ms 5608 KB Ok
74 Correct 75 ms 4720 KB Ok
75 Correct 70 ms 4704 KB Ok
76 Correct 72 ms 6816 KB Ok
77 Correct 69 ms 4344 KB Ok
78 Correct 88 ms 6712 KB Ok
79 Correct 76 ms 6036 KB Ok
80 Correct 76 ms 5700 KB Ok
81 Correct 74 ms 6296 KB Ok
82 Correct 72 ms 5836 KB Ok
83 Correct 71 ms 4924 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Ok
2 Correct 0 ms 212 KB Ok
3 Correct 0 ms 296 KB Ok
4 Correct 1 ms 212 KB Ok
5 Correct 0 ms 212 KB Ok
6 Correct 0 ms 212 KB Ok
7 Correct 0 ms 212 KB Ok
8 Correct 0 ms 292 KB Ok
9 Correct 1 ms 212 KB Ok
10 Correct 1 ms 212 KB Ok
11 Correct 0 ms 292 KB Ok
12 Correct 1 ms 212 KB Ok
13 Correct 0 ms 212 KB Ok
14 Correct 0 ms 212 KB Ok
15 Correct 0 ms 212 KB Ok
16 Correct 0 ms 212 KB Ok
17 Correct 1 ms 212 KB Ok
18 Correct 2 ms 300 KB Ok
19 Correct 7 ms 552 KB Ok
20 Correct 3 ms 468 KB Ok
21 Correct 7 ms 596 KB Ok
22 Correct 4 ms 468 KB Ok
23 Correct 1 ms 212 KB Ok
24 Correct 0 ms 212 KB Ok
25 Correct 0 ms 212 KB Ok
26 Correct 0 ms 212 KB Ok
27 Correct 0 ms 212 KB Ok
28 Correct 0 ms 212 KB Ok
29 Correct 1 ms 292 KB Ok
30 Correct 0 ms 296 KB Ok
31 Correct 0 ms 212 KB Ok
32 Correct 0 ms 212 KB Ok
33 Correct 0 ms 212 KB Ok
34 Correct 0 ms 212 KB Ok
35 Correct 0 ms 212 KB Ok
36 Correct 1 ms 212 KB Ok
37 Correct 0 ms 212 KB Ok
38 Correct 0 ms 212 KB Ok
39 Correct 53 ms 3660 KB Ok
40 Correct 46 ms 3072 KB Ok
41 Correct 89 ms 5068 KB Ok
42 Correct 73 ms 5564 KB Ok
43 Correct 40 ms 2188 KB Ok
44 Correct 66 ms 4568 KB Ok
45 Correct 2 ms 340 KB Ok
46 Correct 1 ms 340 KB Ok
47 Correct 2 ms 340 KB Ok
48 Correct 1 ms 340 KB Ok
49 Correct 1 ms 292 KB Ok
50 Correct 2 ms 212 KB Ok
51 Correct 1 ms 212 KB Ok
52 Correct 2 ms 296 KB Ok
53 Correct 2 ms 292 KB Ok
54 Correct 1 ms 340 KB Ok
55 Correct 3 ms 340 KB Ok
56 Correct 3 ms 468 KB Ok
57 Correct 3 ms 340 KB Ok
58 Correct 3 ms 428 KB Ok
59 Correct 3 ms 340 KB Ok
60 Correct 3 ms 340 KB Ok
61 Correct 3 ms 340 KB Ok
62 Correct 3 ms 340 KB Ok
63 Correct 3 ms 340 KB Ok
64 Correct 3 ms 340 KB Ok
65 Correct 43 ms 1984 KB Ok
66 Correct 62 ms 2096 KB Ok
67 Correct 48 ms 2080 KB Ok
68 Correct 38 ms 1764 KB Ok
69 Correct 43 ms 2032 KB Ok
70 Correct 42 ms 1888 KB Ok
71 Correct 36 ms 1700 KB Ok
72 Correct 37 ms 1752 KB Ok
73 Correct 53 ms 2128 KB Ok
74 Correct 40 ms 1768 KB Ok
75 Correct 47 ms 2096 KB Ok
76 Correct 46 ms 2060 KB Ok
77 Correct 42 ms 1876 KB Ok
78 Correct 36 ms 1740 KB Ok
79 Correct 44 ms 1936 KB Ok
80 Correct 76 ms 5916 KB Ok
81 Correct 77 ms 7364 KB Ok
82 Correct 94 ms 5140 KB Ok
83 Correct 70 ms 6300 KB Ok
84 Correct 73 ms 5608 KB Ok
85 Correct 75 ms 4720 KB Ok
86 Correct 70 ms 4704 KB Ok
87 Correct 72 ms 6816 KB Ok
88 Correct 69 ms 4344 KB Ok
89 Correct 88 ms 6712 KB Ok
90 Correct 76 ms 6036 KB Ok
91 Correct 76 ms 5700 KB Ok
92 Correct 74 ms 6296 KB Ok
93 Correct 72 ms 5836 KB Ok
94 Correct 71 ms 4924 KB Ok
95 Correct 105 ms 4624 KB Ok
96 Correct 147 ms 6476 KB Ok
97 Correct 145 ms 6132 KB Ok
98 Correct 126 ms 5164 KB Ok
99 Correct 133 ms 5660 KB Ok
100 Correct 136 ms 5836 KB Ok
101 Correct 138 ms 6092 KB Ok
102 Correct 128 ms 5652 KB Ok
103 Correct 130 ms 5668 KB Ok
104 Correct 175 ms 6544 KB Ok
105 Correct 142 ms 6360 KB Ok
106 Correct 121 ms 5728 KB Ok
107 Correct 147 ms 6220 KB Ok
108 Correct 149 ms 6568 KB Ok
109 Correct 136 ms 6216 KB Ok
110 Correct 298 ms 19756 KB Ok
111 Correct 295 ms 29584 KB Ok
112 Correct 287 ms 21848 KB Ok
113 Correct 298 ms 25932 KB Ok
114 Correct 296 ms 27320 KB Ok
115 Correct 300 ms 26560 KB Ok
116 Correct 290 ms 26444 KB Ok
117 Correct 306 ms 27316 KB Ok
118 Correct 294 ms 22728 KB Ok
119 Correct 300 ms 28300 KB Ok
120 Correct 289 ms 22936 KB Ok
121 Correct 283 ms 21764 KB Ok
122 Correct 291 ms 24904 KB Ok
123 Correct 304 ms 29636 KB Ok
124 Correct 289 ms 18712 KB Ok
125 Correct 270 ms 11868 KB Ok