# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
737129 | mjhmjh1104 | Present (RMI21_present) | C++17 | 3956 ms | 14056 KiB |
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 <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
int gcd(int x, int y) {
if (!x || !y) return x + y;
return x % y ? gcd(y, x % y) : y;
}
int g[26][26];
bool validate(const int &v) {
for (int i = 0; i < 25; i++) if (v & 1 << i) for (int j = i + 1; j < 25; j++) if (v & 1 << j) {
int k = g[i + 1][j + 1] - 1;
if (~v & 1 << k) return false;
}
return true;
}
int t, k;
vector<int> lt;
int main() {
for (int i = 0; i < 26; i++) for (int j = 0; j < 26; j++) g[i][j] = gcd(i, j);
for (int i = 0; i < 1 << 25; i++) {
if (!validate(i)) continue;
lt.push_back(i);
}
for (scanf("%d", &t); t--; ) {
scanf("%d", &k);
int &c = lt[k];
vector<int> v;
for (int i = 0; i < 25; i++) if (c & 1 << i) v.push_back(i + 1);
printf("%d ", (int)v.size());
for (auto &i: v) printf("%d ", i);
puts("");
}
}
Compilation message (stderr)
# | 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... |