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: 52ms
Memory: 1716kB
In contest: 1276

#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cstdio>
#include <functional>
#include <fstream>
using namespace std;
const int maxn=1e5+10;
const int inf=0x3f3f3f3f;
typedef long long LL;
bool p[1100];
int ans[1100];
int n,t;
void get(){
	memset(p,true,sizeof p);
	for(int i=2;i<=1000;++i)
		if(p[i])
		for(int j=2;i*j<=1000;++j)
			p[i*j]=false;
	int tot=0;
	for(int i=2;i<=1000;++i){
		if(p[i]){
			++tot;
		}
		ans[i]=tot;
	}
}
int main()
{
	scanf("%d",&t);
	get();
	while(t--){
		scanf("%d",&n);
		printf("%d\n",ans[n]);
	}
}