제출 #869256

#제출 시각아이디문제언어결과실행 시간메모리
869256MinaRagy06Present (RMI21_present)C++17
29 / 100
686 ms266216 KiB
#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 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...