#include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;
const int N = 25, MX = 1e6 + 5;
vector<vector<int>> all;
vector<int> gud[N + 1];
int main() {
ios_base::sync_with_stdio(0), cin.tie(0);
all.push_back({});
for (int i = 1; i <= N; i++) {
gud[i].push_back(0);
}
for (int i = 1; i <= N && all.size() < MX; i++) {
for (auto j : gud[i]) {
if (all.size() >= MX) break;
all.push_back(all[j]);
all.back().push_back(i);
bool frq[N + 1]{};
for (auto x : all.back()) frq[x] = 1;
for (int k = i + 1; k <= N; k++) {
bool ok = 1;
for (auto x : all.back()) {
ok &= frq[gcd(x, k)];
}
if (ok) gud[k].push_back(all.size() - 1);
}
}
}
int t;
cin >> t;
while (t--) {
int k;
cin >> k;
cout << all[k].size() << ' ';
for (auto i : all[k]) {
cout << i << ' ';
}
cout << '\n';
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
603 ms |
131560 KB |
Output is correct |
2 |
Correct |
604 ms |
133068 KB |
Output is correct |
3 |
Correct |
599 ms |
132448 KB |
Output is correct |
4 |
Correct |
601 ms |
133948 KB |
Output is correct |
5 |
Correct |
600 ms |
132404 KB |
Output is correct |
6 |
Correct |
601 ms |
132736 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
603 ms |
131560 KB |
Output is correct |
2 |
Correct |
604 ms |
133068 KB |
Output is correct |
3 |
Correct |
599 ms |
132448 KB |
Output is correct |
4 |
Correct |
601 ms |
133948 KB |
Output is correct |
5 |
Correct |
600 ms |
132404 KB |
Output is correct |
6 |
Correct |
601 ms |
132736 KB |
Output is correct |
7 |
Correct |
606 ms |
132064 KB |
Output is correct |
8 |
Correct |
600 ms |
132108 KB |
Output is correct |
9 |
Correct |
597 ms |
131492 KB |
Output is correct |
10 |
Correct |
602 ms |
132968 KB |
Output is correct |
11 |
Correct |
601 ms |
131560 KB |
Output is correct |
12 |
Correct |
599 ms |
133464 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
603 ms |
131560 KB |
Output is correct |
2 |
Correct |
604 ms |
133068 KB |
Output is correct |
3 |
Correct |
599 ms |
132448 KB |
Output is correct |
4 |
Correct |
601 ms |
133948 KB |
Output is correct |
5 |
Correct |
600 ms |
132404 KB |
Output is correct |
6 |
Correct |
601 ms |
132736 KB |
Output is correct |
7 |
Correct |
606 ms |
132064 KB |
Output is correct |
8 |
Correct |
600 ms |
132108 KB |
Output is correct |
9 |
Correct |
597 ms |
131492 KB |
Output is correct |
10 |
Correct |
602 ms |
132968 KB |
Output is correct |
11 |
Correct |
601 ms |
131560 KB |
Output is correct |
12 |
Correct |
599 ms |
133464 KB |
Output is correct |
13 |
Runtime error |
686 ms |
266216 KB |
Execution killed with signal 11 |
14 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
603 ms |
131560 KB |
Output is correct |
2 |
Correct |
604 ms |
133068 KB |
Output is correct |
3 |
Correct |
599 ms |
132448 KB |
Output is correct |
4 |
Correct |
601 ms |
133948 KB |
Output is correct |
5 |
Correct |
600 ms |
132404 KB |
Output is correct |
6 |
Correct |
601 ms |
132736 KB |
Output is correct |
7 |
Correct |
606 ms |
132064 KB |
Output is correct |
8 |
Correct |
600 ms |
132108 KB |
Output is correct |
9 |
Correct |
597 ms |
131492 KB |
Output is correct |
10 |
Correct |
602 ms |
132968 KB |
Output is correct |
11 |
Correct |
601 ms |
131560 KB |
Output is correct |
12 |
Correct |
599 ms |
133464 KB |
Output is correct |
13 |
Runtime error |
686 ms |
266216 KB |
Execution killed with signal 11 |
14 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
603 ms |
131560 KB |
Output is correct |
2 |
Correct |
604 ms |
133068 KB |
Output is correct |
3 |
Correct |
599 ms |
132448 KB |
Output is correct |
4 |
Correct |
601 ms |
133948 KB |
Output is correct |
5 |
Correct |
600 ms |
132404 KB |
Output is correct |
6 |
Correct |
601 ms |
132736 KB |
Output is correct |
7 |
Correct |
606 ms |
132064 KB |
Output is correct |
8 |
Correct |
600 ms |
132108 KB |
Output is correct |
9 |
Correct |
597 ms |
131492 KB |
Output is correct |
10 |
Correct |
602 ms |
132968 KB |
Output is correct |
11 |
Correct |
601 ms |
131560 KB |
Output is correct |
12 |
Correct |
599 ms |
133464 KB |
Output is correct |
13 |
Runtime error |
686 ms |
266216 KB |
Execution killed with signal 11 |
14 |
Halted |
0 ms |
0 KB |
- |