#include <bits/stdc++.h>
using namespace std;
vector <vector <int>> dd;
const int n = 18;
int main () {
for (int i = 0; i < (1 << n); i++) {
vector <int> x;
int freq[n + 1] = {};
for (int j = 0; j < n; j++) {
if ((i >> j) & 1) {
freq[j + 1] = 1;
x.push_back(j + 1);
}
}
bool flag = 0;
for (int i = 0; i < n; i++) for (int j = 1; j < n; j++) {
if (freq[i + 1] && freq[j + 1]) flag |= !freq[__gcd(i + 1, j + 1)];
}
if (flag) continue;
reverse(x.begin(), x.end());
dd.push_back(x);
}
sort(dd.begin(), dd.end());
int t;
cin >> t;
while (t--) {
int k;
cin >> k;
cout << dd[k].size() << " ";
reverse(dd[k].begin(), dd[k].end());
for (auto j : dd[k]) cout << j << " ";
cout << '\n';
reverse(dd[k].begin(), dd[k].end());
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
366 ms |
3572 KB |
Output is correct |
2 |
Correct |
362 ms |
3560 KB |
Output is correct |
3 |
Correct |
366 ms |
3588 KB |
Output is correct |
4 |
Correct |
363 ms |
3452 KB |
Output is correct |
5 |
Correct |
376 ms |
3552 KB |
Output is correct |
6 |
Correct |
365 ms |
3588 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
366 ms |
3572 KB |
Output is correct |
2 |
Correct |
362 ms |
3560 KB |
Output is correct |
3 |
Correct |
366 ms |
3588 KB |
Output is correct |
4 |
Correct |
363 ms |
3452 KB |
Output is correct |
5 |
Correct |
376 ms |
3552 KB |
Output is correct |
6 |
Correct |
365 ms |
3588 KB |
Output is correct |
7 |
Runtime error |
368 ms |
5892 KB |
Execution killed with signal 11 |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
366 ms |
3572 KB |
Output is correct |
2 |
Correct |
362 ms |
3560 KB |
Output is correct |
3 |
Correct |
366 ms |
3588 KB |
Output is correct |
4 |
Correct |
363 ms |
3452 KB |
Output is correct |
5 |
Correct |
376 ms |
3552 KB |
Output is correct |
6 |
Correct |
365 ms |
3588 KB |
Output is correct |
7 |
Runtime error |
368 ms |
5892 KB |
Execution killed with signal 11 |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
366 ms |
3572 KB |
Output is correct |
2 |
Correct |
362 ms |
3560 KB |
Output is correct |
3 |
Correct |
366 ms |
3588 KB |
Output is correct |
4 |
Correct |
363 ms |
3452 KB |
Output is correct |
5 |
Correct |
376 ms |
3552 KB |
Output is correct |
6 |
Correct |
365 ms |
3588 KB |
Output is correct |
7 |
Runtime error |
368 ms |
5892 KB |
Execution killed with signal 11 |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
366 ms |
3572 KB |
Output is correct |
2 |
Correct |
362 ms |
3560 KB |
Output is correct |
3 |
Correct |
366 ms |
3588 KB |
Output is correct |
4 |
Correct |
363 ms |
3452 KB |
Output is correct |
5 |
Correct |
376 ms |
3552 KB |
Output is correct |
6 |
Correct |
365 ms |
3588 KB |
Output is correct |
7 |
Runtime error |
368 ms |
5892 KB |
Execution killed with signal 11 |
8 |
Halted |
0 ms |
0 KB |
- |