标签:color enter top tags sig title ++ 时间 off
本来用数组做标志位,但是测试数据有第1500个,859963392,惹不起哦
---------------------------------------------------------------------------------------------------------------------
class Solution { public: int GetUglyNumber_Solution(int n) { if(n < 7) return n; int ct = 0; unsigned long flag; priority_queue<unsigned long, vector<unsigned long>, greater<unsigned long>> Q; Q.push(1); while(ct < n-1) { unsigned long tmp = Q.top();Q.pop(); if(tmp == flag) { continue; }else ct++; flag = tmp; Q.push(tmp*2),Q.push(tmp*3),Q.push(tmp*5); } while(flag == Q.top())Q.pop(); return Q.top(); } };
标签:color enter top tags sig title ++ 时间 off
原文地址:https://www.cnblogs.com/evidd/p/10625404.html