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

#include<stdio.h>
int g(int x)
{
	int q,w=0;
	for(q=2;q<x;q++)
	{if(x%q==0)
	return 0;}
	return 1;
}
int main()
{
	int i,j,k,n,m,T;
	int f[1010];
	f[1]=0;
	for(i=2;i<=1000;i++)
	{
		if(g(i)==1) f[i]=f[i-1]+1;
		else f[i]=f[i-1];
	}
	scanf("%d",&T);
	for(i=0;i<T;i++)
	{
		scanf("%d",&n);
		printf("%d\n",f[n]);
	}
}