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: 55ms
Memory: 1780kB
In contest: 1276

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<string>
#include<set>
using namespace std;
const int maxn=1e4+50;
const int mod=998244353;

int a[maxn];
bool isprime(int n)
{
	int w=sqrt((double)n)+1;
	for(int i=2;i<=w;i++)
	{
		if(n%i==0) return false;
	}
	return true;
}
void init()
{
	a[2]=1;
	for(int i=3;i<=1500;i++)
	{
		if(isprime(i))
			a[i]=a[i-1]+1;
		else
			a[i]=a[i-1];
	}
}
int main()
{
	init();
	int T;
	scanf("%d",&T);
	while(T--)
	{
		int n;
		scanf("%d",&n);
		printf("%d\n",a[n]);
	}
	return 0;
}