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: 143ms
Memory: 1744kB
In contest: 1276

#include<cstdio>
#include<algorithm>
#include<string>
#include<cstring>
#include<cmath>
#include<iostream>
#include<set>
#include<stdlib.h>
#include<vector>
using namespace std;
const int maxn=110;
const int inf=0x3f3f3f3f;
int jg(int n){
	if(n%2==0)return 0;
	int l=sqrt(n)+1;
	for(int i=3;i<=l;i+=2){
		if(n%i==0)return 0;
	}
	return 1;
}
vector<int>s;
int main(){
	int T;
	scanf("%d",&T);
	int  flag=0;
	for(int i=3;i<=1000;i++){
			if(jg(i)==1){
			s.push_back(i);
			flag++;
			}
	}
	while(T--){
		int n;
		scanf("%d",&n);
		int sum=0;
		for(int i=0;i<=167;i++){
			if(s[i]<=n){
				sum++;
			}
		}
		printf("%d\n",sum);
	}
}