이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;
const int N = 25, MX = 1e6 + 5;
vector<vector<int>> all;
vector<int> gud[N + 1];
int main() {
ios_base::sync_with_stdio(0), cin.tie(0);
all.push_back({});
for (int i = 1; i <= N; i++) {
gud[i].push_back(0);
}
for (int i = 1; i <= N && all.size() < MX; i++) {
for (auto j : gud[i]) {
if (all.size() >= MX) break;
all.push_back(all[j]);
all.back().push_back(i);
bool frq[N + 1]{};
for (auto x : all.back()) frq[x] = 1;
for (int k = i + 1; k <= N; k++) {
bool ok = 1;
for (auto x : all.back()) {
ok &= frq[gcd(x, k)];
}
if (ok) gud[k].push_back(all.size() - 1);
}
}
}
int t;
cin >> t;
while (t--) {
int k;
cin >> k;
cout << all[k].size() << ' ';
for (auto i : all[k]) {
cout << i << ' ';
}
cout << '\n';
}
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... |