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: 648ms
Memory: 2132kB
In contest: 1276

#include<iostream>
#include<cmath>
using namespace std;
int a[100000];
int T,n;
int main()
{
	
	for(int i=1;i<=100000;i++)
	{
		a[i]=0;
		int flag=0;
		for(int j=2;j<=sqrt(i);j++)
		{
			if(i%j==0)
			{
				flag=1;
			}
		}
		if(flag==0)
			a[i]=1;
	}
	scanf("%d",&T);
	while(T--)
	{
		scanf("%d",&n);
		int sum=0;
		for(int i=2;i<=n;i++)
		{
			sum+=a[i];
		}
		printf("%d\n",sum);
	}
}