Start: Jun, 28, 2019 08:42:00
2019杭州师范大学第一届程序设计竞赛新生赛
End: Jun, 28, 2019 11:42:00
Contest has ended!
Time elapsed: 03:00:00
Time remaining: 00:00:00

Problem_ID: F
Result: Accepted
Time: 479ms
Memory: 1092kB
In contest: 1276

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include<stdio.h>
int main(){
	int isprime[1001],i,j,T,n;
	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);
	while(T--){
		int sum=0;
		scanf("%d",&n);
		for(i=2;i<n+1;i++){
			if(isprime[i]==1)
				sum++;
		}
		printf("%d\n",sum);
	}



}