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: 310ms
Memory: 1092kB
In contest: 1276

#include <stdio.h>
int pr(int x) {
	int i;
	for (i = 2;i < x;i++) {
		if (x % i == 0) {
			return 0;
		}
	}
	return 1;
}
int main () {
	int a[1000];
	int n;
	int i,t;
	int ic = 0;
	
	scanf("%d",&t);
	a[2] = 1;
	for (i = 3;i <= 1000;i++) {
	 	a[i] = pr(i);
	}
	while (t--) {
		scanf("%d",&n);
		for (i = 2;i <= n;i++) {
			ic = ic + a[i];
		}
		printf("%d\n",ic);
		ic = 0;
	}
	return 0;
}