Result: Accepted
Time: 55ms
Memory: 1712kB
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <set>
using namespace std;
int i,j,t,n;
int pri(int q)
{
for(j=2;j<=q/2;j++)
{
if(q%j==0)
return 0;
}
return 1;
}
int main()
{
int a[1006];
memset(a,0,sizeof(a));
a[2]=1;
a[3]=2;
for(i=4;i<=1000;i++)
{
if(pri(i))
{
a[i]=a[i-1]+1;
}
else a[i]=a[i-1];
}
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
printf("%d\n",a[n]);
}
}