| 比赛 |
2026初中综合小练习 |
评测结果 |
AAAAA |
| 题目名称 |
求集合中最小的N个数 |
最终得分 |
100 |
| 用户昵称 |
LHS28_ |
运行时间 |
0.195 s |
| 代码语言 |
C++ |
内存使用 |
5.33 MiB |
| 提交时间 |
2026-04-14 20:40:01 |
显示代码纯文本
#include<bits/stdc++.h>
using namespace std;
long long n;
queue<long long> a,b;
int main(){
freopen("minvalinset.in","r",stdin);
freopen("minvalinset.out","w",stdout);
scanf("%d",&n);
cout<<1<<' ';
a.push(3);
b.push(4);
for (int i = 1;i < n;i++){
if (a.front() < b.front()) cout<<a.front()<<' ',a.push(2*a.front()+1),b.push(3*a.front()+1),a.pop();
else if (a.front() == b.front()) a.pop(),i--;
else cout<<b.front()<<' ',a.push(2*b.front()+1),b.push(3*b.front()+1),b.pop();
}
return 0;
}