Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
668 B
2
Indexable
Never
void seive()
{
   ll i,j;
   is_not_prime[0]=1; is_not_prime[1]=1;
   vector<int>v;
   for(i=2;i<=n;i++) 
   {  
       if(is_not_prime[i]==0) 
       { 
          if(i%10 == 2 || i%10 == 3 || i%10 == 5 || i%10 == 7)
          {
            v.pb(i);
          }
          for(j=i*i;j<=n;j+=i) 
          { 
            is_not_prime[j]=1; } 
        }
    }
    ll t;
    cin >> t;
    w(t)
    {
      ll x;
      cin >> x;
      auto it = lower_bound(v.begin(),v.end(),x);
      if(v[it-v.begin()] == x)
      {
        cout << it-v.begin()+1 << endl;
      }
      else
      {
         cout << it-v.begin() << endl;
      }
    }
}