| 比赛 |
2026初中综合小练习 |
评测结果 |
AAAAA |
| 题目名称 |
求集合中最小的N个数 |
最终得分 |
100 |
| 用户昵称 |
hsl_beat |
运行时间 |
0.679 s |
| 代码语言 |
C++ |
内存使用 |
14.58 MiB |
| 提交时间 |
2026-04-14 20:42:13 |
显示代码纯文本
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main()
{
freopen("minvalinset.in", "r", stdin);
freopen("minvalinset.out", "w", stdout);
int n;
cin >> n;
priority_queue<int, vector<int>, greater<int>> pq;
unordered_map<int, bool> mp;
pq.push(1);
int cnt = 0;
while (cnt < n) {
pq.push(2 * pq.top() + 1);
pq.push(3 * pq.top() + 1);
if (mp[pq.top()] == 0) {
cout << pq.top() << ' ';
cnt++;
mp[pq.top()] = 1;
}
pq.pop();
}
return 0;
}