#include <bits/stdc++.h>
using namespace std;
const int N = 2e6 + 10;
const int mx = 1010;
int a, n;
int lc[N], len;
bool vis[N];
void lck() {
int f = sqrt(a);
if (f * f < a) f ++;
for (int i = f; i <= mx; ++ i) {
int f = i * i;
for (int j = f; j <= N; j += f) {
if (vis[j]) continue;
else {
vis[j] = true;
lc[++ len] = j;
}
}
}
sort(lc + 1, lc + len + 1);
}
bool findd(int l, int r, int aim) {
if (l < r) return false;
int mid = (l + r) >> 1;
if (lc[mid] == aim) return true;
else if (lc[mid] >= aim) return findd(l, mid - 1, aim);
else return findd(mid + 1, r, aim);
}
int flck(int l, int r, int aim) {
if (l == r) return lc[l];
int mid = (l + r) >> 1;
if (lc[mid] >= aim) return flck(l, mid, aim);
else return flck(mid + 1, r, aim);
}
int main() {
cin >> a >> n;
lck();
while (n --) {
int x; cin >> x;
int lk = flck(1, len, x);
if (lk == x) cout << "lucky\n";
else cout << lk << endl;
}
return 0;
}
小杨的幸运数
最新推荐文章于 2024-09-06 10:38:06 发布