Submission #737129

#TimeUsernameProblemLanguageResultExecution timeMemory
737129mjhmjh1104Present (RMI21_present)C++17
29 / 100
3956 ms14056 KiB
#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)

Main.cpp: In function 'int main()':
Main.cpp:30:15: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |     for (scanf("%d", &t); t--; ) {
      |          ~~~~~^~~~~~~~~~
Main.cpp:31:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |         scanf("%d", &k);
      |         ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...