优先队列的第一道题,做这道题的时候完全就是拆了东墙补西墙,题目里面的格式需要好好注意一下,,,
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mk make_pair
#define sz(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pa;
int main() {
priority_queue<ll, vector<ll>, greater<ll> > q;
q.push(1);
map<ll, int> mp;
for (int i = 1; i < 1500; i++) {
ll x = q.top();
q.pop();
if (mp.find(x * 2) == mp.end()) { q.push(x * 2); mp[x * 2] = 1; }
if (mp.find(x * 3) == mp.end()) { q.push(x * 3); mp[x * 3] = 1; }
if (mp.find(x * 5) == mp.end()) { q.push(x * 5); mp[x * 5] = 1; }
//if (i == 1499) cout << "The 1500'th ugly number is " << x << "." << endl;
}
cout << "The 1500'th ugly number is " << q.top() << "." << endl;
return 0;
}