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

#include<stdio.h>
#include<math.h>
int main()
{
	int a[1100]={0},j,b,c,i,t,n,k,flag=1;
	float m,h;
	a[2]=1;
	a[3]=2;
	scanf("%d",&t);
	for(j=4;j<=1000;j++)
	{   m=(float)j;
		h=sqrt(m);
		b=(int)h+1;
		flag=1;
		for(i=2;i<=b;i++)
		{
			if(j%i==0){flag=0;break;}
		}
		if(flag==0) a[j]=a[j-1];
		else  a[j]=a[j-1]+1;
	}
	for(i=1;i<=t;i++)
	{
		scanf("%d",&k);
		printf("%d\n",a[k]);
		
	}
	
   return 0;	
}