用了优先队列,还是超时

class Solution {
public:
int nthSuperUglyNumber(int n, vector<int>& primes) {
priority_queue<int,std::vector<int>,std::greater<int> > pq;
pq.push(1);
int i=1;
int t;
while(i<=n){
if(t == pq.top())
{
pq.pop();
continue;
}
t=pq.top();
pq.pop();
for(auto k:primes)
pq.push(t*k);
i++;
// cout<<t<<" ";
}
return t;
}
};

  

LeetCode() Super Ugly Number的更多相关文章

  1. [LeetCode] Super Ugly Number 超级丑陋数

    Write a program to find the nth super ugly number. Super ugly numbers are positive numbers whose all ...

  2. [LeetCode] Super Ugly Number (Medium)

    Super Ugly Number 最后WA没做出来. typedef long long int64; #define MAXBOUND 10000000 class Solution { publ ...

  3. [LeetCode] 313. Super Ugly Number 超级丑陋数

    Write a program to find the nth super ugly number. Super ugly numbers are positive numbers whose all ...

  4. Leetcode 313. super ugly number

    Write a program to find the nth super ugly number. Super ugly numbers are positive numbers whose all ...

  5. leetcode 263. Ugly Number 、264. Ugly Number II 、313. Super Ugly Number 、204. Count Primes

    263. Ugly Number 注意:1.小于等于0都不属于丑数 2.while循环的判断不是num >= 0, 而是能被2 .3.5整除,即能被整除才去除这些数 class Solution ...

  6. Super Ugly Number -- LeetCode

    Write a program to find the nth super ugly number. Super ugly numbers are positive numbers whose all ...

  7. [LintCode] Super Ugly Number 超级丑陋数

    Write a program to find the nth super ugly number. Super ugly numbers are positive numbers whose all ...

  8. 313. Super Ugly Number

    题目: Write a program to find the nth super ugly number. Super ugly numbers are positive numbers whose ...

  9. [Swift]LeetCode313. 超级丑数 | Super Ugly Number

    Write a program to find the nth super ugly number. Super ugly numbers are positive numbers whose all ...

随机推荐

  1. 字符编码和python .encode().decode()方法

    字符编码与encode.decode的问题:  用8个开关表示世界万物   ASCII :  American Standard Code for Information Interchange,美国 ...

  2. arm嵌入式交叉编译工具链

    1.arm-linux-gcc 常用的参数:-o[制定输出文件名] -c[只到编译停止,不连接] -g[键入调试信息] -xO[优化级别] -w/W(警告等级) arm-linux-gcc -o de ...

  3. POJ 题目1141 Brackets Sequence(区间DP记录路径)

    Brackets Sequence Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 27793   Accepted: 788 ...

  4. [DNS][转]EDNS

    随着业务的复杂化和多样化,RFC1035中定义的DNS消息格式和它支持的消息内容已经不足以满足一些DNS服务器的需求,于是,RFC2671 中提出了一种扩展DNS机制EDNS(Extension Me ...

  5. 关于WebView的复习

    最近不知为啥,公司提出要用webView,偷笑不止.在青软上课的时候学过这东西,是说条件比较紧张的时候可以拿来充数的,现在公司里手机端开发人员很多,做的好好的,放着原生ui不用,非要赶时髦搞什么Web ...

  6. ad画fpc

    得到新技能 后记: 实际情况,复杂很多pin的fpc 都是用cad画的.我明天学...

  7. CLR线程池

    WaitCallback 表示要在 ThreadPool 线程上执行的回调方法. 创建委托,方法是将回调方法传递给 WaitCallback 构造函数. 您的方法必须具有此处所显示的签名. 如果想使用 ...

  8. WEB框架介绍

    python  web框架分类 自己实现socket Tornado 借助wsgi实现socket Django:因为Django用的wsgi,所以不用操作socket. wsgi有很多,如下, MV ...

  9. LeetCode 7 -- String to Integer (atoi)

    Implement atoi to convert a string to an integer. 转换很简单,唯一的难点在于需要开率各种输入情况,例如空字符串,含有空格,字母等等. 另外需在写的时候 ...

  10. Android锁屏或灭屏状态下,快速按两次音量下键实现抓拍功能(1.2Framework层使用startService形式实现)

        如前一篇博文所分析,我们可以使用广播的形式在快速按下两次音量下键的时候发出广播,以方便客户端进行捕捉.既然有两种方式可以实现该Issue那么哪种方式是首选呢?     我个人推荐使用启动服务的 ...