#include <bits/stdc++.h>
using namespace std;
vector <vector <int>> dd;
const int n = 25;
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';
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1575 ms |
148952 KB |
Output is correct |
2 |
Correct |
1542 ms |
147388 KB |
Output is correct |
3 |
Correct |
1632 ms |
149212 KB |
Output is correct |
4 |
Correct |
1555 ms |
148808 KB |
Output is correct |
5 |
Correct |
1540 ms |
147604 KB |
Output is correct |
6 |
Correct |
1559 ms |
149404 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1575 ms |
148952 KB |
Output is correct |
2 |
Correct |
1542 ms |
147388 KB |
Output is correct |
3 |
Correct |
1632 ms |
149212 KB |
Output is correct |
4 |
Correct |
1555 ms |
148808 KB |
Output is correct |
5 |
Correct |
1540 ms |
147604 KB |
Output is correct |
6 |
Correct |
1559 ms |
149404 KB |
Output is correct |
7 |
Correct |
1535 ms |
148176 KB |
Output is correct |
8 |
Correct |
1581 ms |
148528 KB |
Output is correct |
9 |
Correct |
1589 ms |
147856 KB |
Output is correct |
10 |
Correct |
1537 ms |
149188 KB |
Output is correct |
11 |
Correct |
1548 ms |
147648 KB |
Output is correct |
12 |
Correct |
1530 ms |
148956 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1575 ms |
148952 KB |
Output is correct |
2 |
Correct |
1542 ms |
147388 KB |
Output is correct |
3 |
Correct |
1632 ms |
149212 KB |
Output is correct |
4 |
Correct |
1555 ms |
148808 KB |
Output is correct |
5 |
Correct |
1540 ms |
147604 KB |
Output is correct |
6 |
Correct |
1559 ms |
149404 KB |
Output is correct |
7 |
Correct |
1535 ms |
148176 KB |
Output is correct |
8 |
Correct |
1581 ms |
148528 KB |
Output is correct |
9 |
Correct |
1589 ms |
147856 KB |
Output is correct |
10 |
Correct |
1537 ms |
149188 KB |
Output is correct |
11 |
Correct |
1548 ms |
147648 KB |
Output is correct |
12 |
Correct |
1530 ms |
148956 KB |
Output is correct |
13 |
Runtime error |
1518 ms |
298512 KB |
Execution killed with signal 11 |
14 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1575 ms |
148952 KB |
Output is correct |
2 |
Correct |
1542 ms |
147388 KB |
Output is correct |
3 |
Correct |
1632 ms |
149212 KB |
Output is correct |
4 |
Correct |
1555 ms |
148808 KB |
Output is correct |
5 |
Correct |
1540 ms |
147604 KB |
Output is correct |
6 |
Correct |
1559 ms |
149404 KB |
Output is correct |
7 |
Correct |
1535 ms |
148176 KB |
Output is correct |
8 |
Correct |
1581 ms |
148528 KB |
Output is correct |
9 |
Correct |
1589 ms |
147856 KB |
Output is correct |
10 |
Correct |
1537 ms |
149188 KB |
Output is correct |
11 |
Correct |
1548 ms |
147648 KB |
Output is correct |
12 |
Correct |
1530 ms |
148956 KB |
Output is correct |
13 |
Runtime error |
1518 ms |
298512 KB |
Execution killed with signal 11 |
14 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1575 ms |
148952 KB |
Output is correct |
2 |
Correct |
1542 ms |
147388 KB |
Output is correct |
3 |
Correct |
1632 ms |
149212 KB |
Output is correct |
4 |
Correct |
1555 ms |
148808 KB |
Output is correct |
5 |
Correct |
1540 ms |
147604 KB |
Output is correct |
6 |
Correct |
1559 ms |
149404 KB |
Output is correct |
7 |
Correct |
1535 ms |
148176 KB |
Output is correct |
8 |
Correct |
1581 ms |
148528 KB |
Output is correct |
9 |
Correct |
1589 ms |
147856 KB |
Output is correct |
10 |
Correct |
1537 ms |
149188 KB |
Output is correct |
11 |
Correct |
1548 ms |
147648 KB |
Output is correct |
12 |
Correct |
1530 ms |
148956 KB |
Output is correct |
13 |
Runtime error |
1518 ms |
298512 KB |
Execution killed with signal 11 |
14 |
Halted |
0 ms |
0 KB |
- |