标签:count int main prim max for als find pat
/*1007 ??êy??2???*/
#include <cstdio>
const int maxn = 10000001;
int prime[maxn]={0};
bool p[maxn] = {0};
int pnum =0;
void Find_prime(int n)
{
for(int i=2; i<=n; i++)
{
if(p[i] == false)
{
prime[pnum++] = i;
for(int j=i+i; j<= n; j+=i)
{
p[j] = true;
}
}
}
}
int main()
{
int n,count=0;
scanf("%d",&n);
Find_prime(n);
for(int i=0; i<pnum; i++)
{
if(prime[i+1] - prime[i] == 2)
count++;
}
printf("%d",count);
return 0;
}
标签:count int main prim max for als find pat
原文地址:https://www.cnblogs.com/hebust/p/9498140.html