全re,想死
查看原帖
全re,想死
1069088
lxy_ayaka楼主2023/12/25 19:15
#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); 
	freopen("3383.txt","r",stdin);
	cin >> n >> q;
	fill(x+2,x+n+1,1);
	
	for(int i=1;i<=q;i++){
		cin >> 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]=0;
				if(j%p[r]==0) break;
			}
			if(k==cnt){
				cout << p[k] <<endl;
				break;
			}
		}
		cnt=0;
	}
	
}
2023/12/25 19:15
加载中...