This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <iomanip>
#include <cassert>
#include <deque>
#include <functional>
#include <set>
#include <queue>
#include <unordered_map>
#include <map>
#include <iomanip>
#include <complex>
using namespace std;
int gcd(int a, int b) {
if (!b) {
return a;
}
return gcd(b, a % b);
}
int32_t main() {
int t;
cin >> t;
while (t--) {
int sum = 0;
int k;
cin >> k;
const int n = 20;
for (int mask = 0; mask < (1 << n); ++mask) {
bool ok = true;
vector<int> curr;
vector<int> have(n + 1, 0);
for (int j = 0; j < n; ++j) {
if ((1 << j) & mask) {
have[j + 1] = 1;
curr.push_back(j + 1);
}
}
vector<int> cnt(n + 1, 0);
for (int j = n; j >= 1; --j) {
for (int x = j; x <= n; x += j) {
cnt[j] += have[x];
}
cnt[j] = cnt[j] * (cnt[j] - 1) / 2;
for (int x = j * 2; x <= n; x += j) {
cnt[j] -= cnt[x];
}
if (cnt[j]) {
if (!have[j]) {
ok = false;
}
}
}
sum += ok;
if (sum == k + 1) {
cout << curr.size() << ' ';
for (int i : curr) {
cout << i << ' ';
}
cout << endl;
break;
}
}
}
}
# | 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... |