Yuexingfei_qwq @ 2024-07-07 10:22:03
0分,全部RE。有没有大佬帮忙看一下,感谢!!!
#include <bits/stdc++.h>
#include <iostream>
#include <time.h>
#include <stdlib.h>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <math.h>
#include <stack>
#include <vector>
#include <queue>
using namespace std;
typedef long long ll;
int n, q;
bool b[1010000];
int ans[1010000], l = 0;
signed main() {
scanf ("%d%d", &n, &q);
memset(b, 0, sizeof(b));
for (int i = 2; i <= n; i++) {
if (!b[i]) {
ans[++l] = i;
}
for (int j = 1; j <= l && i * ans[j] <= n; j++) {
b[i * ans[j]] = 1;
if (i % ans[j] == 0) {
break;
}
}
}
while (q--) {
int x;
scanf ("%d", &x);
printf ("%d\n", ans[x]);
}
return 0;
}
by CloudsUnfolding @ 2024-07-07 16:58:59
数组开小了
by Yuexingfei_qwq @ 2024-07-07 20:32:50
@CloudsUnfolding A了,谢谢!已关