Result: Accepted
Time: 192ms
Memory: 1720kB
#include<cstdio>
#include<algorithm>
#include<string>
#include<cstring>
#include<cmath>
#include<iostream>
#include<set>
#include<stdlib.h>
#include<vector>
using namespace std;
const int maxn=110;
const int inf=0x3f3f3f3f;
int jg(int n){
if(n%2==0)return 0;
for(int i=3;i<n;i+=2){
if(n%i==0)return 0;
}
return 1;
}
vector<int>s;
int main(){
int T;
scanf("%d",&T);
s.push_back(2);
for(int i=3;i<=1000;i++){
if(jg(i)==1){
s.push_back(i);
}
}
//printf("%d\n",flag);
// for(int i=0;i<=167;i++){
// printf("%d %d\n",i,s[i]);
// }
while(T--){
int n;
scanf("%d",&n);
int sum=0;
for(int i=0;i<=167;i++){
if(s[i]<=n&&s[i]!=0){
sum++;
}
else if(s[i]>n){
break;
}
}
printf("%d\n",sum);
}
}