이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#ifdef BLAT
#include "debug/debug.hpp"
#else
#define debug(x...)
#endif
using namespace std;
void printSet(long long set, int setidx = 0) {
// cout << "S" << setidx << " = ";
cout << __builtin_popcountll(set) << ' ';
for (int i = 1; i <= 40; i++)
if (set & (1LL << i))
cout << i << ' ';
cout << endl;
}
void generateNextSet(long long &mask) {
for (int i = 1; i <= 40; i++) {
mask ^= (1LL << i);
if (mask & (1LL << i)) {
break;
}
}
queue <int> q;
for (int i = 1; i <= 40; i++)
for (int j = 1; j <= 40; j++)
if ((mask & (1LL << i)) && (mask & (1LL << j))) {
int g = __gcd(i, j);
if (!(mask & (1LL << g))) {
mask |= (1LL << g);
q.push(g);
}
}
while (q.size()) {
int fr = q.front();
q.pop();
for (int i = 1; i <= 40; i++)
if ((mask & (1LL << i))) {
int g = __gcd(fr, i);
if (!(mask & (1LL << g))) {
mask |= (1LL << g);
q.push(g);
}
}
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
long long set = 2;
vector <long long> sets = {0};
for (int i = 1; i <= 1000000; i++) {
sets.push_back(set);
generateNextSet(set);
}
debug(sets.size());
int t;
cin >> t;
while (t--) {
int k;
cin >> k;
printSet(sets[k]);
}
return 0;
}
# | 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... |