#include <bits/stdc++.h>
using namespace std;
const int A = 1e5 + 100;
bool exist[A];
vector<vector<int>> vecs;
int main(){
vecs.push_back({});
for (int mx = 1; mx <= 100 and vecs.size() < 1000000; mx ++){
for (int i = 0; i <= mx; i ++)
exist[i] = 0;
vector<int> nvec;
vector<vector<int>> nvecs;
for (auto vec : vecs){
bool good = 1;
for (int x : vec)
exist[x] = 1;
for (int x : vec)
if (!exist[gcd(x, mx)])
good = 0;
for (int x : vec)
exist[x] = 0;
if (good){
nvec = vec;
nvec.push_back(mx);
nvecs.push_back(nvec);
}
}
for (auto vec : nvecs)
vecs.push_back(vec);
// cout << mx << " :: " << nvecs.size() << endl;
}
// for (auto vec : vecs){
// cout << vec.size() << " : ";
// for (int x : vec)
// cout << x << " ";
// cout << endl;
// }
int t;
cin >> t;
while(t--){
int k;
cin >> k;
cout << vecs[k].size() << " ";
for (int x : vecs[k])
cout << x << " ";
cout << endl;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |