답안 #593498

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
593498 2022-07-11T09:36:50 Z pakhomovee Present (RMI21_present) C++17
8 / 100
1442 ms 288 KB
#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;
            }
        }
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Incorrect 1442 ms 288 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Incorrect 1442 ms 288 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Incorrect 1442 ms 288 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Incorrect 1442 ms 288 KB Output isn't correct
8 Halted 0 ms 0 KB -