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: 499ms
Memory: 1096kB
In contest: 1276

#include<stdio.h>
#include<math.h>
void is(int a[]);
int a[1001]={0};
int main()
{
    int t,i,j,n;
	scanf("%d",&t);
	is(a);
	for(i=0;i<t;i++){
		scanf("%d",&n);	
		int count=0;
		for(j=2;j<=n;j++){
			if(a[j]==1){
				count++;
			}
		}
	printf("%d\n",count);
	}
	return 0;
}
void is(int a[])
{
	int i,j;
	for(i=2;i<1001;i++){
		if(i%2!=0){
		    int count=0;
			for(j=2;j<i;j++){
				if(i%j==0){
					count++;
				}
			}
			if(count==0){
				a[i]=1;
			}
		}else if(i==2){
			a[i]=1;
		}
	}
}