/* -*- coding: utf-8 -*- * * 2806.cc: No.2806 Cornflake Man - yukicoder */ #include #include #include using namespace std; /* constant */ const int MAX_N = 200000; /* typedef */ using ll = long long; using umii = unordered_map; /* global variables */ int as[MAX_N], bs[MAX_N]; bool used[MAX_N]; /* subroutines */ /* main */ int main() { int n, m; scanf("%d%d", &n, &m); for (int i = 0; i < n; i++) scanf("%d", as + i); sort(as + 1, as + n); umii aps; for (int i = 1; i < n; i++) aps[as[i]] = i; int k = 0; for (int i = 1; i < n; i++) { if (! used[i]) { used[i] = true; for (int ax = as[i] * 2; ax <= m; ax += as[i]) { if (! aps.count(ax)) { puts("-1"); return 0; } used[aps[ax]] = true; } bs[k++] = as[i]; } } printf("%d\n", k); for (int j = 0; j < k; j++) printf("%d%c", bs[j], (j + 1 < k) ? ' ' : '\n'); return 0; }