还错了qwp
查看原帖
还错了qwp
625696
zhuhanle2011楼主2023/11/5 19:25
#include <bits/stdc++.h>
using namespace std;
bool iszsbl[100000010];
int zsbl[6000010], cnt = 0;

void zs(int n) {
	memset(iszsbl, 1, sizeof(iszsbl));
	iszsbl[1] = 0;

	for (int i = 2; i <= n; i++) {
		if (iszsbl[i])
			zsbl[++cnt] = i;

		for (int j = 1; j <= cnt && i * zsbl[j] <= n; j++) {
			iszsbl[i * zsbl[j]] = 0;

			if (i % zsbl[j] == 0)
				break;
		}
	}
}

int main() {
	std::ios::sync_with_stdio(0);
	int n, q;
	cin >> n >> q;
	zs(n);
	while (q--) {
		int k;
		cin >> k;
		cout << zsbl[k];
	}
	return 0;
}
2023/11/5 19:25
加载中...