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

#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<cmath>
#include<cctype>
#include<algorithm>
using namespace std;
int a[1005] = {0};
void mmm(int a[], int x) {
	int i, j;
	a[2] = 1;
	a[3] = 1;
	a[5] = 1;
	for(i = 2; i <= x; i++) {
		int flag = 0;
		for(j = 2; j <= sqrt(double(i)) + 1; j++) {
			if(j == i / 2 + 1)
				a[i] = 1;
			if(i % j == 0){
				flag = 1;
				break;
			}
		}
		if(flag == 0)
			a[i] = 1;
	}

}
int main(){
	mmm(a, 1000);
	int t;
	scanf("%d", &t);
	int n, i, j;
	while(t--) {
		scanf("%d", &n);
		int count = 0;
		for(i = 2; i <= n; i++) {
			if(a[i] == 1)
				count++;
		}
		printf("%d", count);
		if(t != 0)
			printf("\n");
	}
	return 0;

}