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 ...
随机推荐
- Asp.net MVC 示例
public ActionResult Browse(string id){ using (musicstoreEntities db = new musicstoreEntities( ...
- UliPad ----python 开发利器
安装wxPython ...
- nim也玩一行流,nim版的list comprehension
nim 是一门风格类似python的静态编译型语言,官方网站:http://nim-lang.org 如果你想折腾nim的编辑环境,可以用sublime text3 +插件nimlime,notepa ...
- 使用composer安装项目依赖
Composer 是 PHP 的一个依赖管理工具.它允许你申明项目所依赖的代码库,它会在你的项目中为你安装他们 下载并安装composer composer官方文档有好几种安装方法,此处只介绍我实验过 ...
- mysql 大小写问题-sql-mode问题
一.mysql 字段名 表名 数据库名 是否区分大小写 今天碰到数据库大小写问题,linux与windows下问题 同时又碰到保留字 http://www.cnblogs.com/lawdong/ar ...
- docker 源码分析 四(基于1.8.2版本),Docker镜像的获取和存储
前段时间一直忙些其他事情,docker源码分析的事情耽搁了,今天接着写,上一章了解了docker client 和 docker daemon(会启动一个http server)是C/S的结构,cli ...
- javascript获取asp.net服务器端控件的值
代码如下: <%@ Page Language="C#" CodeFile="A.aspx.cs" Inherits="OrderManage_ ...
- UGUI与DOtween的坑
在使用ugui和dotween做动画时,如使用transform.DoMoveX,.DoLocalMoveX,.DoMove,.DoLocalMove等方法时,动画效果有可能是错误的,什么时候错误呢? ...
- 数据结构《19》----String容器的三种实现
一.序言 一个简单的string 容器到底是如何实现的? 本文给出了 String 的三种从易到难的实现,涉及了 reference counting, copy on write 的技术. 二.第一 ...
- Eclipse+Python+Selenium自动化测试框架搭建
1.下载Eclipse:http://www.eclipse.org/downloads/ 2.下载JDK:http://www.oracle.com/technetwork/java/javaee/ ...