#include <bits/stdc++.h>
using namespace std;
vector <vector <int>> dd;
const int n = 35;
vector <int> cur;
int freq[n + 1];
void gen (int pos) {
if (pos == n + 1) {
dd.push_back(cur);
reverse(dd.back().begin(), dd.back().end());
return;
}
gen(pos + 1);
bool flag = 0;
for (auto i : cur) {
flag |= !freq[__gcd(pos, i)];
}
if (flag) return;
cur.push_back(pos); freq[pos] = 1; gen(pos + 1);
cur.pop_back(); freq[pos] = 0;
}
int main () {
gen(1);
sort(dd.begin(), dd.end());
int t;
cin >> t;
while (t--) {
int k;
cin >> k;
cout << dd[k].size() << " ";
for (int i = dd[k].size() - 1; i >= 0; i--) {
cout << dd[k][i] << " ";
}
cout << '\n';
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2720 ms |
524288 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2720 ms |
524288 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2720 ms |
524288 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2720 ms |
524288 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2720 ms |
524288 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |