Need a unique gift idea?
A Pastebin account makes a great Christmas gift
SHARE
TWEET

Untitled

a guest Jun 23rd, 2018 54 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  1. #include <iostream>
  2. #include<bits/stdc++.h>
  3. using namespace std;
  4. #define ll long long
  5. bool isPrime(ll int n)
  6. {
  7.     // Corner cases
  8.     if (n <= 1)  return false;
  9.     if (n <= 3)  return true;
  10.  
  11.     // This is checked so that we can skip
  12.     // middle five numbers in below loop
  13.     if (n%2 == 0 || n%3 == 0) return false;
  14.  
  15.     for (ll int i=5; i*i<=n; i=i+6)
  16.         if (n%i == 0 || n%(i+2) == 0)
  17.            return false;
  18.  
  19.     return true;
  20. }
  21.  
  22. int main() {
  23.    //ll int m=10000100000;
  24.     ll int t,m,n;
  25.     cin>>t;
  26.     while(t--)
  27.     {
  28.       cin>>m>>n;
  29.       for(ll int i=m;i<=n;i++)
  30.       {
  31.           if(isPrime(i))
  32.            cout<<i<<" ";
  33.       }
  34.       cout<<endl;
  35.       //segmentedsieve(m,n+1);
  36.     }
  37.     //cout<<m;
  38. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top