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

#include<stdio.h>
#include<math.h>
int main(){
	int T,n,sum;
	int a[1001]={0};
	scanf("%d",&T);
	while(T--){
		sum=0;
		scanf("%d",&n);
		for(int i=2;i<=n;i++){
		if(a[i]==0){
		for(int j=i;j*i<=n;j++){
			a[j*i]=1;
		}
	    }
	}
		for(int i=2;i<=n;i++){
			if(a[i]==0)
			sum++;
			
		}
		printf("%d\n",sum);
		
		
		
	}
	return 0;
}