#include <stdio.h>
#define N 1000000
#define A 25
int gcd(int a, int b) {
return b == 0 ? a : gcd(b, a % b);
}
int good(int s, int b) {
int a;
for (a = 1; a < b; a++)
if ((s & 1 << a) != 0 && (s & 1 << gcd(a, b)) == 0)
return 0;
return 1;
}
int main() {
static int ss[N + 1];
int t, n, i, a;
scanf("%d", &t);
n = 0;
ss[n++] = 0;
for (a = 1; a <= A; a++)
for (i = 0; i < n && n <= N; i++)
if ((ss[i] & 1 << a) == 0 && good(ss[i], a))
ss[n++] = ss[i] | 1 << a;
while (t--) {
int cnt;
scanf("%d", &i);
cnt = 0;
for (a = 1; a <= A; a++)
if ((ss[i] & 1 << a) != 0)
cnt++;
printf("%d", cnt);
for (a = 1; a <= A; a++)
if ((ss[i] & 1 << a) != 0)
printf(" %d", a);
printf("\n");
}
return 0;
}
Compilation message
Main.c: In function 'main':
Main.c:23:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
23 | scanf("%d", &t);
| ^~~~~~~~~~~~~~~
Main.c:33:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
33 | scanf("%d", &i);
| ^~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
237 ms |
4148 KB |
Output is correct |
2 |
Correct |
236 ms |
4076 KB |
Output is correct |
3 |
Correct |
236 ms |
4180 KB |
Output is correct |
4 |
Correct |
240 ms |
4100 KB |
Output is correct |
5 |
Correct |
236 ms |
4136 KB |
Output is correct |
6 |
Correct |
237 ms |
4184 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
237 ms |
4148 KB |
Output is correct |
2 |
Correct |
236 ms |
4076 KB |
Output is correct |
3 |
Correct |
236 ms |
4180 KB |
Output is correct |
4 |
Correct |
240 ms |
4100 KB |
Output is correct |
5 |
Correct |
236 ms |
4136 KB |
Output is correct |
6 |
Correct |
237 ms |
4184 KB |
Output is correct |
7 |
Correct |
237 ms |
4176 KB |
Output is correct |
8 |
Correct |
235 ms |
4124 KB |
Output is correct |
9 |
Correct |
236 ms |
4100 KB |
Output is correct |
10 |
Correct |
237 ms |
4088 KB |
Output is correct |
11 |
Correct |
235 ms |
4128 KB |
Output is correct |
12 |
Correct |
236 ms |
4064 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
237 ms |
4148 KB |
Output is correct |
2 |
Correct |
236 ms |
4076 KB |
Output is correct |
3 |
Correct |
236 ms |
4180 KB |
Output is correct |
4 |
Correct |
240 ms |
4100 KB |
Output is correct |
5 |
Correct |
236 ms |
4136 KB |
Output is correct |
6 |
Correct |
237 ms |
4184 KB |
Output is correct |
7 |
Correct |
237 ms |
4176 KB |
Output is correct |
8 |
Correct |
235 ms |
4124 KB |
Output is correct |
9 |
Correct |
236 ms |
4100 KB |
Output is correct |
10 |
Correct |
237 ms |
4088 KB |
Output is correct |
11 |
Correct |
235 ms |
4128 KB |
Output is correct |
12 |
Correct |
236 ms |
4064 KB |
Output is correct |
13 |
Runtime error |
241 ms |
8156 KB |
Execution killed with signal 11 |
14 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
237 ms |
4148 KB |
Output is correct |
2 |
Correct |
236 ms |
4076 KB |
Output is correct |
3 |
Correct |
236 ms |
4180 KB |
Output is correct |
4 |
Correct |
240 ms |
4100 KB |
Output is correct |
5 |
Correct |
236 ms |
4136 KB |
Output is correct |
6 |
Correct |
237 ms |
4184 KB |
Output is correct |
7 |
Correct |
237 ms |
4176 KB |
Output is correct |
8 |
Correct |
235 ms |
4124 KB |
Output is correct |
9 |
Correct |
236 ms |
4100 KB |
Output is correct |
10 |
Correct |
237 ms |
4088 KB |
Output is correct |
11 |
Correct |
235 ms |
4128 KB |
Output is correct |
12 |
Correct |
236 ms |
4064 KB |
Output is correct |
13 |
Runtime error |
241 ms |
8156 KB |
Execution killed with signal 11 |
14 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
237 ms |
4148 KB |
Output is correct |
2 |
Correct |
236 ms |
4076 KB |
Output is correct |
3 |
Correct |
236 ms |
4180 KB |
Output is correct |
4 |
Correct |
240 ms |
4100 KB |
Output is correct |
5 |
Correct |
236 ms |
4136 KB |
Output is correct |
6 |
Correct |
237 ms |
4184 KB |
Output is correct |
7 |
Correct |
237 ms |
4176 KB |
Output is correct |
8 |
Correct |
235 ms |
4124 KB |
Output is correct |
9 |
Correct |
236 ms |
4100 KB |
Output is correct |
10 |
Correct |
237 ms |
4088 KB |
Output is correct |
11 |
Correct |
235 ms |
4128 KB |
Output is correct |
12 |
Correct |
236 ms |
4064 KB |
Output is correct |
13 |
Runtime error |
241 ms |
8156 KB |
Execution killed with signal 11 |
14 |
Halted |
0 ms |
0 KB |
- |