优先队列始终弹出最小,注意有重复的也要弹出来
然后3*i+2什么的push进去自动排序
第几小要模拟或举小的例子试一试就知道了

#include<bits/stdc++.h>
using namespace std;
#define N 100011
typedef long long ll;
typedef pair<ll,int> PII;
int n,m,k;
ll an=1;
int a[6]={1,2,3,5,8};
priority_queue<ll,vector<ll>,greater<ll> > pq;
set<int> b;
int main()
{
for(int i=0;i<5;i++)
{
pq.push(a[i]);
//int j=a[i];
//b.insert(j);
//b.insert(3*j+2);
//b.insert(5*j+3);b.insert(8*j+5);
}
//set<int>::iterator it;
//for(it=b.begin();it!=b.end();it++) cout<<*it<<" ";
while(an<2020)///为什么an=1且<2020,问就是试出来的,举8看怎么组合是对的
{
ll t=pq.top();
pq.pop();
//cout<<t;
while(t==pq.top())
{
pq.pop();
}
an++;
pq.push(3*t+2);
pq.push(5*t+3);
pq.push(8*t+5);
}
cout<<pq.top();
return 0;
}
///10000 200;