/* -*- coding: utf-8 -*- * * 2081.cc: No.2081 Make a Test Case of GCD Subset - yukicoder */ #include #include #include using namespace std; /* constant */ const int MAX_N = 100000; const int MAX_P = 100000; /* typedef */ typedef vector vi; /* global variables */ bool primes[MAX_P + 1]; int as[MAX_N]; /* subroutines */ int gen_primes(int maxp, vi &pnums) { fill(primes, primes + maxp + 1, true); primes[0] = primes[1] = false; int p; for (p = 2; p * p <= maxp; p++) if (primes[p]) { pnums.push_back(p); for (int q = p * p; q <= maxp; q += p) primes[q] = false; } for (; p <= maxp; p++) if (primes[p]) pnums.push_back(p); return (int)pnums.size(); } /* main */ int main() { vi pnums; int pn = gen_primes(MAX_P, pnums); //printf("pn=%d\n", pn); int m; scanf("%d", &m); int n = 0, pi = 0; while (m > 0) { int l = 1; while ((1 << (l + 1)) - 1 <= m) l++; m -= (1 << l) - 1; for (int i = 0; i < l; i++) as[n++] = pnums[pi]; pi++; } for (int i = 0; i < n; i++) as[i] *= pnums[pi++]; printf("%d\n", n); for (int i = 0; i < n; i++) printf("%d%c", as[i], (i + 1 < n) ? ' ' : '\n'); return 0; }