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

#include<stdio.h>
#include<math.h>
prime(int n)
{
	int i;
	for(i=2;i<=sqrt(n);i++)
	    if(n%i==0)
	        return 0;
	return 1;
}
int main()
{
	int T,n,count,i;
	int a[1100]={0};
	
	for(i=2;i<=1000;i++)
	    a[i]=prime(i);
    
    scanf("%d",&T);
    
    while(T--)
    {
    	scanf("%d",&n);
    	count=0;
    	for(i=1;i<=n;i++)
    	    count+=a[i];
    	printf("%d\n",count);
	}
    
    return 0;
}