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

#include<stdio.h>
#include<string.h>
bool vis[1001];
int main() {
	int t,n;
	scanf("%d",&t);
	for(int i=2; i<=1000; i++) {
		if(!vis[i]) {
			for(int j=2; i*j<=1000; j++) {
				vis[i*j]=1;
			}
		}
	}
	while(t--) {
		int ans=0;
		scanf("%d",&n);
		for(int i=1; i<=n; i++) {
			if(!vis[i]) ++ans;
		}
		printf("%d\n",ans-1);
	}
}