Result: Accepted
Time: 51ms
Memory: 1716kB
#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
*/