Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- typedef long double ld;
- int main() {
- ios_base::sync_with_stdio(0); cin.tie(0), cout.tie(0);
- // Решето по нечетным числам
- ld n; cin >> n;
- vector<bool> v((n-1)/2+1, 1);
- for (ld i = 3; i*i<=n; i+=2)
- if (v[(i-1)/2])
- for (ld j = i*i; j<=n; j+=2*i)
- v[(j-1)/2] = 0;
- cout << "2 ";
- for (ld i = 1; i<v.size(); i++)
- if (v[i]) cout << 2*i+1 << ' ';
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement