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: 112ms
Memory: 1480kB
In contest: 1276

#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<map>
#include<stack>
#include<math.h>;
#include<queue>
using namespace std;
const int maxn=1e5+10;
int  a[maxn];
int main() {
	int t;
	scanf("%d",&t);
	a[0]=2;
	int cnt=1;
	for(int i=3; i<=1005; i++) {
		int flag=1;
		for(int j=2; j<i; j++) {
			if(i%j==0) {
				flag=0;
				break;
			}
		}
		if(flag==1)a[cnt++]=i;
	}
	while(t--) {
		int n;
		scanf("%d",&n);
		int ans=0;
		for(int i=0; i<cnt; i++) {
			if(a[i]<=n)ans++;
			else break;
		}
		printf("%d\n",ans);
	}
}