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: 478ms
Memory: 1116kB
In contest: 1276

#include<stdio.h>
#include<math.h>

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