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: 56ms
Memory: 2100kB
In contest: 1276

#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
int gcd(int a,int b)
{
	return b?gcd(b,a%b):a;
}
int t,n,k;
int x[maxn];
string s;
int f(int x)
{
	int m=sqrt(x);
	for(int i=2;i<=m;i++)
	{
		if(x%i==0)return 0;
	}
	return 1;
}
int main()
{
	for(int i=2;i<=10000;i++)
	{
		x[i]=x[i-1];
		if(f(i))x[i]++;
	}
	scanf("%d",&t);
	while(t--)
	{
		scanf("%d",&n);
		printf("%d\n",x[n]);
	}
}