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: 47ms
Memory: 2008kB
In contest: 1276

#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<set>
#include<map>
#include<cstring>
using namespace std;
const int maxn=1e5+100;
const int inf=0x3f3f3f3f;
struct rule{
	bool operator()(const int &a1,const int &a2){
		return a1>a2;
	}
};
bool chan(int k){
	for(int i=2;i<(int)sqrt(k*1.0)+1;i++){
		if(k%i==0) return 0;
	}
	return 1;
}
int main(){
	int t,a[maxn];
	scanf("%d",&t);
	a[0]=0;
	for(int i=2;i<=1000;i++){
		a[i]+=a[i-1]+chan(i);
	}
	while(t--){
		int n,tot=0;
		scanf("%d",&n);
		printf("%d\n",a[n]);
	}
}