Result: Accepted
Time: 54ms
Memory: 1748kB
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<map>
#include<queue>
#include<vector>
#include<algorithm>
using namespace std;
const int maxn=1010;
typedef long long ll;
int a[maxn];
int sum[maxn];
int main(){
memset(a,0,sizeof(a));
a[2]=1;
int flag=0;
for(int i=3;i<=1000;i++){
flag=0;
for(int j=2;j<=sqrt((double)i);j++){
if(i/j*j==i){
flag=1;
break;
}
}
if(flag==0)
a[i]=1;
}
sum[1]=0;
for(int i=2;i<=1000;i++){
if(a[i]==1){
sum[i]=sum[i-1]+1;
}
else{
sum[i]=sum[i-1];
}
}
int t;
scanf("%d",&t);
while(t--){
int n;
scanf("%d",&n);
printf("%d\n",sum[n]);
}
return 0;
}