-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdprob.cpp
More file actions
38 lines (35 loc) · 694 Bytes
/
dprob.cpp
File metadata and controls
38 lines (35 loc) · 694 Bytes
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
#include<bits/stdc++.h>
using namespace std;
void init_code(){
#ifndef ONLINE_JUDGE
freopen("inputf.in","r",stdin);
freopen("outputf.out","w",stdout);
#endif
}
void isprimes(int n, int m){
bool prime[m+1];
for(int p=2; p*p<=m; p++){
if (prime[p]==false){
for(int j=p*p; j<=m; j+=p){
prime[j]=true;
}
}
}
for (int q=n; q<=m; q++){
if (prime[q]==false && q!=1){
cout << q << ' ';
}
}
}
int main(){
init_code();
int t;
cin>>t;
for (int k=0; k<t; k++) {
int m,n;
cin>>n>>m;
isprimes(n,m);
cout<<endl;
}
return 0;
}