이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |