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

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<list>
#include<math.h>
#include<vector>
#include<stack>
#include<string>
#include<set>
#include<map>
#include<numeric>
#include<stdio.h>
#include<functional>
#include<time.h>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int maxn = 1e5 + 10;
const ull mode = 10092272478850909;
const int inf = 0x3f3f3f3f;
const double pi = 3.14159265358979323846264338327950;
template <class T> inline T min(T a, T b, T c) { return min(min(a, b), c); }
template <class T> inline T max(T a, T b, T c) { return max(max(a, b), c); }
template <class T> inline T min(T a, T b, T c, T d) { return min(min(a, b), min(c, d)); }
template <class T> inline T max(T a, T b, T c, T d) { return max(max(a, b), max(c, d)); }

ll ans[1111];

int isPrime(int x)
{
	int i,mmm=1;
	double limit;
	if(x<=1)
		 mmm=0;
	else if(x==2)
		 mmm=1;
	else if(x%2==0)
		mmm=0;
	else
	{
		double t=x;
		limit=sqrt(t)+1;
		for(i=3;i<limit;i+=2)
		{
			if(x%i==0)
			{ 
				mmm=0;
				break;
			}
		}
	}
	return mmm;
}
int main()
{
    int t;
	scanf("%d",&t);
	for(int i=2;i<1111;i++)
		if(isPrime(i))
			ans[i]=ans[i-1]+1;
		else
			ans[i]=ans[i-1];
	for(int p=0;p<t;p++)
	{
		int n;
		scanf("%d",&n);
		printf("%d\n",ans[n]);
	}
	return 0;
}