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

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<math.h>
#include<cstring>
#include<queue>
#include<string>
using namespace std;

#define ll long long
const int INF = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const int maxn = 1e3 + 10;

int num[maxn];
bool check(int x)
{
	if(x == 2)
		return true;
	for(int i=2;i * i <= x;i++)
	{	
		if(x % i == 0)
			return false;
	}
	return true;
}
int main()
{
	memset(num,0,sizeof num);
	for(int i=2;i<=maxn;i++)
		if(check(i))
		{
			num[i] = num[i-1];
			num[i]++;
			//cout<<i<<endl;
		}
		else 
			num[i] = num[i-1];
	
	int t;
	scanf("%d",&t);
	while(t--)
	{
		int n;
		scanf("%d",&n);
		printf("%d\n",num[n]);
	}
}
/*
char s[100];
int main()
{
	int t;
	scanf("%d",&t);
	while(t--)
	{
		scanf("%s",s);
		int len = strlen(s);
		int tot = 0;
		for(int i=0;i<len;i++)
			if(s[i] == 'a' || s[i] == 'e' || s[i] == 'i' || s[i] == 'o' || s[i] == 'u')
				tot++;
		printf("%d\n",tot);
	}
}
*/

/*

CTS201906083

*/