为什么为什么为什么为什么有没有打捞邦邦
查看原帖
为什么为什么为什么为什么有没有打捞邦邦
1069088
lxy_ayaka楼主2023/12/26 19:41
#include<bits/stdc++.h>
using namespace std;

const int N=1e8+10;
bool x[N];
long long n,q,k,p[N],cnt=0;

int main(){
	std::ios::sync_with_stdio(0);
	cout.tie(0);
	//freopen("3383.txt","r",stdin);
	//
freopen("33832.txt","w",stdout);
	scanf("%ld%ld",&n,&q);
//	fill(x+2,x+n+1,1);
	
	for(int i=1;i<q;i++){
		scanf("%ld",&k);
		for(int j=2;j<=n;j++){
			if(!x[j]) p[++cnt]=j;
			for(int r=1;p[r]*j<=n;r++){
				x[p[r]*j]=1;
				if(j%p[r]==0) break;
			}
			if(k==cnt){
				cout << p[k] <<endl;
				break;
			}
		}
		cnt=0;
	}
}
2023/12/26 19:41
加载中...