50 lines
585 B
C++
50 lines
585 B
C++
|
#include <iostream>
|
|||
|
#include<cstdio>
|
|||
|
#include<algorithm>
|
|||
|
#include <cmath>
|
|||
|
#include <cstdlib>
|
|||
|
using namespace std;
|
|||
|
const int N=1e7+5;
|
|||
|
int pr[N/10];//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
bool b[N];//<2F>Dz<EFBFBD><C7B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
int q,n;
|
|||
|
int t1=0,t;
|
|||
|
int cnt=0;
|
|||
|
void prime()
|
|||
|
{
|
|||
|
for(int i=2;i<N;i++)
|
|||
|
{
|
|||
|
if(!b[i])
|
|||
|
{
|
|||
|
pr[++cnt]=i;
|
|||
|
}
|
|||
|
for(int j=1;j<=cnt&&pr[j]*i<N;j++)
|
|||
|
{
|
|||
|
b[pr[j]*i]=1;
|
|||
|
if(i%pr[j]==0)
|
|||
|
{
|
|||
|
break;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
void ce()
|
|||
|
{
|
|||
|
cout<<cnt;
|
|||
|
// for(int i=1;i<=cnt;i++)
|
|||
|
// {
|
|||
|
// cout<<pr[i]<<" ";
|
|||
|
// }
|
|||
|
}
|
|||
|
int main()
|
|||
|
{
|
|||
|
prime();
|
|||
|
ce();
|
|||
|
// scanf("%d",&t);
|
|||
|
// while(t--)
|
|||
|
// {
|
|||
|
// scanf("%d",&n);
|
|||
|
// }
|
|||
|
return 0;
|
|||
|
}
|