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: 54ms
Memory: 1752kB
In contest: 1276

#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<stdlib.h>
#include<string.h>
using namespace std;
const int MAXN=1e4+6;
int a[MAXN];
int main()
{
	int n,t;
	int cnt=0;
	memset(a,0,sizeof(a));
	for(int i=2;i<=1000;i++)
	{
		bool flag=false;
		for(int j=2;j<i;j++)
			if(i%j==0)
			{
				//printf("i:%d\n",i);
				flag=true;
				break;
			}
		if(!flag)
		{
			cnt++;
			//printf("cnt:%d\n",cnt);
		}
		a[i]=cnt;
	}
	scanf("%d",&t);
	while(t--)
	{
		scanf("%d",&n);
		printf("%d\n",a[n]);
	}
	return 0;
}