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

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <set>
using namespace std;
int i,j,t,n;
int pri(int q)
{
	for(j=2;j<=q/2;j++)
	{
		if(q%j==0)
			return 0;
	}
	return 1;
}

int main()
{
	int a[1006];
	memset(a,0,sizeof(a));
	a[2]=1;
	a[3]=2;
	for(i=4;i<=1000;i++)
	{
		if(pri(i))
		{
			a[i]=a[i-1]+1;
		}
		else a[i]=a[i-1];
	}	
	scanf("%d",&t);
	while(t--)
	{
		scanf("%d",&n);
		printf("%d\n",a[n]);
	}
}