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

#include<stdio.h>
#include<string.h>
#include<math.h>
int main(){
	int T,i,n,m,flag,j,k,a[1001]={0};
	for(i=2;i<=1001;++i)
		{
			flag=1;
			for(j=2;j<i/2+1;++j)
			{
				if(i%j==0)
				{
					flag=0;				
				}
			}
				if(flag==1)
				{
					++a[i];
				}
		}
	scanf("%d",&T);
	while(T--)
	{
		m=0;
		scanf("%d",&n);
		for(i=2;i<=n;++i)
		{
			m+=a[i];
		}
		printf("%d\n",m);
	}
}