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: 461ms
Memory: 1716kB
In contest: 1276

#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int prime[1050];

int main()
{
	int T;
	cin>>T;
	for(int i=2;i<=1040;i++)
	{
		for(int j=2;j<i;j++)
			if(i%j==0)
			{
				prime[i]=1;
				break;
			}
	}
	while(T--)
	{
		int n;int ans=0;
		scanf("%d",&n);
		for(int i=2;i<=n;i++)
			if(!prime[i])
				ans++;
		printf("%d\n",ans);
	}
	return 0;
}