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: 1900ms
Memory: 1092kB
In contest: 1276

#include<stdio.h>
#include<math.h>
#include<string.h>
int main()
{
	int T=0;
	scanf("%d",&T);
	for(int s=0;s<T;s++)
	    {
	    	int n;
	    	scanf("%d",&n);
		int vis[1006];
	memset(vis,0,sizeof(vis));
	for(int i=2;i<=n;i++)
	for(int j=i*2;j<=n;j+=i) vis[j] = 1;
	int sum=0;
	for(int i=2;i<=n;i++)
	if(vis[i]==0)
		sum++;
		printf("%d\n",sum);
		}
	return 0;
}