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

#include<stdio.h>
#include<math.h>
int main(void)
{
	int t,n,i,j,k,limit,sum,a[1001];
	scanf("%d",&t);
	for(j=3;j<=1000;j++)
	{
		limit=sqrt((double)j)+1;
		for(k=2;k<=limit;k++)
		{
			if(j%k==0){a[j]=1;break;}
		}
	}
	for(i=0;i<t;i++)
	{
		scanf("%d",&n);
		sum=1;
		for(j=3;j<=n;j++)
		{
			if(a[j]!=1)sum++;
		}
		printf("%d\n",sum);
	}
}