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: 1840ms
Memory: 1116kB
In contest: 1276

#include<stdio.h>
#include<math.h>
int main(){
	int n,m,b,c,x,y,t,i,j,k;
	int limit,flag;
	scanf("%d",&t);
	while(t--){
	scanf("%d",&n);
	x=1;
	
	for(i=3;i<=n;i+=2){
		flag=1;
		if(i!=3&&i%3==0)
			continue;
		else if(i!=5&&i%5==0)
			continue;
	  limit=sqrt((float)i)+1;
	  for(j=3;j<=limit;j+=2){
		  if(i%j==0){
			flag=0;
			break;
		  }
	  }
	if(flag)
		x++;}
	printf("%d\n",x);


	}

	return 0;}