https://vjudge.net/problem/UVA-136
#include<iostream>
#include<set>
#include<queue>
#include<vector>
#include<algorithm>
using namespace std;
#pragma warning(disable:4996)
const int maxn = 1005;
struct cmp {//重载()符号
bool operator()(const long long a, const long long b) {//a优先级小于b时返回true
return a > b;
}
};
int main(){
#ifdef _DEBUG
freopen("in", "rb", stdin);
//freopen("out", "wb", stdout);
#endif // _DEBUG
set<long long> vis;
priority_queue<long long, vector<long long>, cmp > all;
all.push(1);
vis.insert(1);
int cnt = 0;
while (1) {
long long int x = all.top(); all.pop();
if (++cnt == 1500) { printf("The 1500'th ugly number is %lld.\n", x); break; }
if (!vis.count(2 * x)) vis.insert(2 * x), all.push(2 * x);
if (!vis.count(3 * x)) vis.insert(3 * x), all.push(3 * x);
if (!vis.count(5 * x)) vis.insert(5 * x), all.push(5 * x);
}
}