-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.cpp
45 lines (40 loc) · 1.41 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/* *****************************************************************
* BISMILLAHIR RAHMANIR RAHIM *
* *
* Md. Rezwanul Haque *
* CSE-2K14 (KUET) *
* Gmail : [email protected] *
* Khulna University of Engineering & Technology, Bangladesh. *
*****************************************************************
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define MX 100000005
int status[(MX/32)+2];
void sieve() {
int i, j, sqrtN,cnt=0;
sqrtN = int( sqrt( MX ) );
printf("2\n");
cnt++;
for( i = 3; i <= sqrtN; i += 2 )
///if( Check(status[i>>5],i&31)==0)
if(!(status[i>>5] & (1<<(i&31)))) {
if(!(cnt%100)) printf("%d\n",i);
cnt++;
for( j = i*i; j <= MX; j += (i<<1) )
///status[j>>5]= Set(status[j>>5],j & 31);
status[j>>5]= status[j>>5] | (1<<(j&31));
}
for(i=sqrtN+1; i<=MX; i+=2)
///if( Check(status[i>>5],i&31)==0)
if(!(status[i>>5] & (1<<(i&31)))) {
if(!(cnt%100)) printf("%d\n",i);
cnt++;
}
return;
}
int main() {
sieve();
return 0;
}