LeetCode() Super Ugly Number
用了优先队列,还是超时
- 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的更多相关文章
- [LeetCode] Super Ugly Number 超级丑陋数
Write a program to find the nth super ugly number. Super ugly numbers are positive numbers whose all ...
- [LeetCode] Super Ugly Number (Medium)
Super Ugly Number 最后WA没做出来. typedef long long int64; #define MAXBOUND 10000000 class Solution { publ ...
- [LeetCode] 313. Super Ugly Number 超级丑陋数
Write a program to find the nth super ugly number. Super ugly numbers are positive numbers whose all ...
- Leetcode 313. super ugly number
Write a program to find the nth super ugly number. Super ugly numbers are positive numbers whose all ...
- 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 ...
- Super Ugly Number -- LeetCode
Write a program to find the nth super ugly number. Super ugly numbers are positive numbers whose all ...
- [LintCode] Super Ugly Number 超级丑陋数
Write a program to find the nth super ugly number. Super ugly numbers are positive numbers whose all ...
- 313. Super Ugly Number
题目: Write a program to find the nth super ugly number. Super ugly numbers are positive numbers whose ...
- [Swift]LeetCode313. 超级丑数 | Super Ugly Number
Write a program to find the nth super ugly number. Super ugly numbers are positive numbers whose all ...
随机推荐
- C# dll加载,抽象方法的使用
抽象类! dll的使用 /// <summary> /// 返回类型--插件 /// </summary> /// <param name="baseName& ...
- 百度地图结合echarts并添加行政区块
作者:LJaer链接:https://www.zhihu.com/question/49251513/answer/125728764来源:知乎<!DOCTYPE html> <ht ...
- install graph-tool
try this if ubuntu version is >= 14.04 sudo apt-get update sudo apt-get upgrade sudo apt-get -y i ...
- 关于ajax跨域请求(cross Domain)
Cross Domain AJAX主要就是A.com网站的页面发出一个XMLHttpRequest,这个Request的url是B.com,这样的请求是被禁止的,浏览器处于安全考虑不允许进行跨域访问, ...
- Java Json Object 互转
官方网址: http://json-lib.sourceforge.net/ 需要准备的jar包 1. json-lib-2.4-jdk15.jar 目前最新版, 下载地址 http: ...
- ios开发之网络php
接着前面的学习,几天上午学习了数据库网络值php用户的注册与登录,感觉代码与ios上的oc太相似了,因此学习下来没什么障碍了,下面是代码: 首先是javascript.html文件中: <!DO ...
- android开发虚拟机不能正常启动
点击 window---perspective---DDMS---查看设备状态, 如果显示没有可用设备,则在AVD manager中重 启即可, 若列表中有设备,但显示offline 可采用一下方式 ...
- LeetCode 21 -- Merge Two Sorted Lists
Merge two sorted linked lists and return it as a new list. The new list should be made by splicing t ...
- js版扫雷(可直接运行试玩)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- 用 Express4 写一个简单的留言板
Knowledge Dependence:阅读文本前,你需要熟悉 Node.js 编程.Express 以及相关工具和常用中间件的使用. Node.js 以其单线程异步非阻塞的特点,越来越被广大的 W ...