Start: Jun, 28, 2019 08:42:00
2019杭州师范大学第一届程序设计竞赛新生赛
End: Jun, 28, 2019 11:42:00
Time elapsed:
Time remaining:

Problem_ID: F
Result: Accepted
Time: 53ms
Memory: 1720kB
In contest: 1276

#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<iostream>
#include<stdlib.h>
#include<math.h>
#include<map>
#include<set>
#include<queue>
#include<vector>
using namespace std;
int prime[1010],r[1010]={0};
void p(void){
	for(int i=2;i<=1005;i++){
		prime[i]=1;
	}
	for(int i=2;i<=1000;i++){
		for(int j=2;i*j<=1005;j++){
			prime[i*j]=0;
		}
	}
}
int main()
{
	int T,x;
	cin>>T;
	p();
	for(int i=1;i<=1005;i++){
		if(prime[i]==1) r[i]=r[i-1]+1;
		else r[i]=r[i-1];
	}
	//printf("%d\n",rank[8]);
	while(T--){
		scanf("%d",&x);
		printf("%d\n",r[x]);
	}
}