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: 192ms
Memory: 1720kB
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;
	for(int i=3;i<n;i+=2){
		if(n%i==0)return 0;
	}
	return 1;
}
vector<int>s;
int main(){
	int T;
	scanf("%d",&T);
	s.push_back(2);
	for(int i=3;i<=1000;i++){
		if(jg(i)==1){
			s.push_back(i);
		}
	}
	//printf("%d\n",flag);
//	for(int i=0;i<=167;i++){
//		printf("%d %d\n",i,s[i]);
//	}
	while(T--){
		int n;
		scanf("%d",&n);
		int sum=0;
		for(int i=0;i<=167;i++){
			if(s[i]<=n&&s[i]!=0){
				sum++;
			}
			else if(s[i]>n){
				break;
			}
		}
		printf("%d\n",sum);
	}
}