比赛 2026初中综合小练习 评测结果 WWWWW
题目名称 求集合中最小的N个数 最终得分 0
用户昵称 Youth 运行时间 0.015 s
代码语言 C++ 内存使用 3.63 MiB
提交时间 2026-04-14 21:00:37
显示代码纯文本
#include <bits/stdc++.h>
using namespace std;
int n;
priority_queue<long long,vector<long long>,greater<long long> > q;
int main(){
    freopen("minvalinset.in","r",stdin);
    freopen("minvalinset.out","w",stdout);
    cin>>n;
    q.push(1);
    int u=q.top();
    while(n--){
        if(u==q.top())continue;
        u=q.top();
        q.pop();
        q.push((u<<1)+1);
        q.push(u*3+1);
        cout<<u<<' ';
    }
    return 0;
}