Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <sstream>
- #include <vector>
- #include <set>
- #include <bitset>
- #include <map>
- #include <deque>
- #include <string>
- #include <algorithm>
- #include <numeric>
- #include <cstdio>
- #include <cassert>
- #include <cstdlib>
- #include <cstring>
- #include <ctime>
- #include <cmath>
- #define pb push_back
- #define pbk pop_back
- #define mp make_pair
- #define fs first
- #define sc second
- #define all(x) (x).begin(), (x).end()
- #define foreach(i, a) for (__typeof((a).begin()) i = (a).begin(); i != (a).end(); ++i)
- #define len(a) ((int) (a).size())
- #ifdef CUTEBMAING
- #define eprintf(...) fprintf(stderr, __VA_ARGS__)
- #else
- #define eprintf(...) 42
- #endif
- using namespace std;
- typedef long long int64;
- typedef long double ld;
- typedef unsigned long long lint;
- const int inf = (1 << 30) - 1;
- const int64 linf = (1ll << 62) - 1;
- int main() {
- int n; cin >> n;
- vector<int> is_prime(n + 1, true), primes;
- is_prime[0] = is_prime[1] = 0;
- for (int i = 2; i * i <= n; i++) {
- if (is_prime[i]) {
- for (int j = i * i; j <= n; j += i) {
- is_prime[j] = false;
- }
- }
- }
- vector<int> ans;
- for (int i = 1; i <= n; i++) {
- if (is_prime[i]) {
- int q = 1;
- while (q <= n / i) {
- q *= i;
- ans.push_back(q);
- }
- }
- }
- cout << len(ans) << endl;
- for (int i : ans) {
- printf("%d ", i);
- }
- puts("");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement