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: 485ms
Memory: 1368kB
In contest: 1276

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



}