Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <bits/stdc++.h>
- using namespace std;
- #define max 1000000000
- #define ll long long int
- bool a[1000000002];
- void compute() {
- memset(a,true,sizeof(a));
- a[1]=false;
- for(ll i=2;i<=sqrt(max);i++) {
- for(ll j=i*i;j<=max;j+=i) {
- a[j]=false;
- }
- }
- }
- int main() {
- ios_base::sync_with_stdio(false);
- cin.tie(NULL); cout.tie(NULL);
- int t;
- cin >> t;
- compute();
- while(t--) {
- ll n1,n2;
- cin>>n1>>n2;
- for(ll i=n1;i<=n2;i++) {
- if(a[i]) cout << i << endl;
- }
- cout << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment