题目描述
blablabla
样例
blablabla
算法1
class Solution {
public:
int getUglyNumber(int n) {
priority_queue<long,vector<long>, greater<long> > pq;
pq.push(1);
long lastnum=0;
for (int i=1;i<=n;i++) {
long top=pq.top();
pq.pop();
if (lastnum==top) {
i-=1;
continue;
}
lastnum=top;
pq.push(top*2);
pq.push(top*3);
pq.push(top*5);
}
return lastnum;
}
};