Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define ll long long
- #define test int t; cin>>t; for(int cs=1;cs<=t;cs++)
- #define maX 1000008
- vector<ll>xx;
- bool marked[maX];
- void sieve()
- {
- marked[0]=1;
- marked[1]=1;
- for(ll i=4; i<=maX; i+=2)
- {
- marked[i]=1;
- }
- for(ll i=3; i<=maX; i+=2)
- {
- if(marked[i]==0)
- {
- for(ll j=i*i; j<=maX; j+=i+i)
- {
- marked[j]=1;
- }
- }
- }
- }
- int main()
- {
- ios_base::sync_with_stdio(0);
- cin.tie(0);
- cout.tie(0);
- sieve();
- ll a,c,d,e,i,j;
- cin>>a>>c;
- for(i=a;i<=c;i++)
- {
- if(marked[i]==0)
- {
- cout<<i<<" ";
- }
- }
- cout<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment