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: 1744kB
In contest: 1276

#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<iostream>
using namespace std;
int a[1010];
int isprime(int x)
{
	if(x<=1)
	return 0;
	else if(x==2)
	return 1;
	else
	{
		for(int i=2;i<=sqrt(x)+1;i++)
		if(x%i==0)
		return 0;
		return 1;
	}
}
int main()
{
	int T,n;
	scanf("%d",&T);
	a[1]=0,a[2]=1,a[0]=0;
	for(int i=3;i<=1000;i++)
	{
		if(isprime(i))
		a[i]=a[i-1]+1;
		else
		a[i]=a[i-1];
	}
	while(T--)
	{
		scanf("%d",&n);
		printf("%d\n",a[n]);
	}
	return 0;
}