Result: Accepted
Time: 53ms
Memory: 1744kB
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<iostream>
using namespace std;
int a[1010];
int isprime(int x)
{
if(x<=1)
return 0;
else if(x==2)
return 1;
else
{
for(int i=2;i<=sqrt(x)+1;i++)
if(x%i==0)
return 0;
return 1;
}
}
int main()
{
int T,n;
scanf("%d",&T);
a[1]=0,a[2]=1,a[0]=0;
for(int i=3;i<=1000;i++)
{
if(isprime(i))
a[i]=a[i-1]+1;
else
a[i]=a[i-1];
}
while(T--)
{
scanf("%d",&n);
printf("%d\n",a[n]);
}
return 0;
}