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

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
using namespace std;
#define ll long long
const int maxn=1010;
int a[maxn];

int main ()
{
	memset(a,0,sizeof(a));
	a[1]=0;
	for(int i=2;i<=1000;i++)
	{
		int lazy=0;
		a[i]=a[i-1];
		for(int j=2;j*j<=i;j++)
		{
			if(i%j==0)
			{
				lazy=1;
				break;
				
			}
		}
		if(lazy==0)
		{
			a[i]=a[i]+1;
		}
	}
	int t;
	scanf("%d",&t);
	while(t--)
	{
		int x;
		scanf("%d",&x);
		printf("%d\n",a[x]);
	}
}