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: 100ms
Memory: 1740kB
In contest: 1276

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>
#include<map>
using namespace std;
typedef long long ll;
int isp(int x)
{
	if(x==2) return 1;
	else if(x%2==0) return 0;
	for(int i=3;i<=sqrt(x)+1;i=i+2)
	{
		if(x%i==0)
		{
			return 0;
		}
	}
	return 1;
}
int main()
{
	int p=1;
	int a[1010];
	for(int i=2;i<=5000;i++)
	{
		if(isp(i))
		{
			a[p]=i;
			p++;
		}
	}
	int t;
	int m;
	scanf("%d",&t);
	while(t--)
	{
		int ans=0;
		scanf("%d",&m);
		for(int i=1;i<p;i++)
		{
			if(a[i]>m)
			{
				ans=i-1;
				break;
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}