Result: Accepted
Time: 47ms
Memory: 2008kB
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<set>
#include<map>
#include<cstring>
using namespace std;
const int maxn=1e5+100;
const int inf=0x3f3f3f3f;
struct rule{
bool operator()(const int &a1,const int &a2){
return a1>a2;
}
};
bool chan(int k){
for(int i=2;i<(int)sqrt(k*1.0)+1;i++){
if(k%i==0) return 0;
}
return 1;
}
int main(){
int t,a[maxn];
scanf("%d",&t);
a[0]=0;
for(int i=2;i<=1000;i++){
a[i]+=a[i-1]+chan(i);
}
while(t--){
int n,tot=0;
scanf("%d",&n);
printf("%d\n",a[n]);
}
}