1 条题解
-
0
C++ :
#include <bits/stdc++.h> using namespace std; bool vis[1100000]; int main() { int a, n; cin >> a >> n; vector<int> ans; // 存储幸运数字 // 能得出当x=1000001 最差的幸运数为1002001,1002001为完全平方数 for (int i = ceil(sqrt(a)); i <= 1001; i++) { int x = i * i; // x为完全平方数 for (int j = 1; j * x <= 1002001; j++) { if (!vis[x * j]) //超级幸运数的倍数 { ans.push_back(x * j); vis[x * j] = true; } } } sort(ans.begin() , ans.end()); while (n--) { int x; cin >> x; if (vis[x]) cout << "lucky" << endl; else { int pos = upper_bound(ans.begin(), ans.end(), x) - ans.begin(); cout << ans[pos] << endl; } } return 0; }
信息
- ID
- 5655
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- (无)
- 标签
- 递交数
- 0
- 已通过
- 0
- 上传者