7.7 Design an algorithm to find the kth number such that the only prime factors are 3,5, and 7.

这道题跟之前LeetCode的那道Ugly Number II 丑陋数之二基本没有啥区别,具体讲解可参见那篇,代码如下:

class Solution {
public:
int getKthMagicNumber(int k) {
vector<int> res(, );
int i3 = , i5 = , i7 = ;
while (res.size() < k) {
int m3 = res[i3] * , m5 = res[i5] * , m7 = res[i7] * ;
int mn = min(m3, min(m5, m7));
if (mn == m3) ++i3;
if (mn == m5) ++i5;
if (mn == m7) ++i7;
res.push_back(mn);
}
return res.back();
}
};

[CareerCup] 7.7 The Number with Only Prime Factors 只有质数因子的数字的更多相关文章

  1. PAT-1059 Prime Factors (素数因子)

    1059. Prime Factors Given any positive integer N, you are supposed to find all of its prime factors, ...

  2. 1059. Prime Factors (25)

    时间限制 50 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 HE, Qinming Given any positive integer N, y ...

  3. PAT 1059. Prime Factors (25) 质因子分解

    题目链接 http://www.patest.cn/contests/pat-a-practise/1059 Given any positive integer N, you are suppose ...

  4. 2014辽宁ACM省赛 Prime Factors

    问题 L: Prime Factors 时间限制: 1 Sec  内存限制: 128 MB [提交][状态][论坛] 题目描写叙述 I'll give you a number , please te ...

  5. PAT1059:Prime Factors

    1059. Prime Factors (25) 时间限制 100 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 HE, Qinming Given ...

  6. A1059. Prime Factors

    Given any positive integer N, you are supposed to find all of its prime factors, and write them in t ...

  7. PAT 甲级 1059 Prime Factors

    https://pintia.cn/problem-sets/994805342720868352/problems/994805415005503488 Given any positive int ...

  8. (笔试题)质数因子Prime Factor

    题目: Given any positive integer N, you are supposed to find all of its prime factors, and write them ...

  9. PAT 1059 Prime Factors[难]

    1059 Prime Factors (25 分) Given any positive integer N, you are supposed to find all of its prime fa ...

随机推荐

  1. MySQL学习基础 之 起航篇

    MySQL 学习来自慕课网<与MySQL的零距离接触> MySQL是一个开源的关系型数据库管理系统 MySQL分为社区版和企业版 MySQL登录和退出相关的命令 参数 描述 -D,--da ...

  2. android studio annotation 配置过程

    参考了好些配置,发现总有这样,那样的问题. 环境:androidstudio 1.5 preview 2 sdk 6.0 1.首先新建一个android项目. 过程略 2.配置project的buil ...

  3. 最新Burpsuite Pro v1.7.03 介绍和破解版下载

    0x00 介绍 Burp Suite 是用于攻击web 应用程序的集成平台.它包含了许多工具,并为这些工具设计了许多接口,以促进加快攻击应用程序的过程.所有的工具都共享一个能处理并显示HTTP 消息, ...

  4. 在Mac 系统上安装密码生成器

    1.打开终端 2.输入 ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/ins ...

  5. Windows Log4日志发送到ElasticSearch

    处理多行数据到elasticsearch Nxlog 配置 <Input in> Module im_file File "E:\\log\\webapi\\\err.log&q ...

  6. linux进程间通信-有名管道(FIFO)

    有名管道(FIFO) 命名管道也被称为FIFO文件,是一种特殊的文件.由于linux所有的事物都可以被视为文件,所以对命名管道的使用也就变得与文件操作非常统一. (1)创建命名管道 用如下两个函数中的 ...

  7. jmeter的使用(一)

    1.下载jmeter:http://jmeter.apache.org/download_jmeter.cgi 2.启动jmeter,打开jmeter.bat 3.添加线程组 4.添加http请求 5 ...

  8. AD批量创建用户

    实验环境:Windows Server 2008R 2 由于测试需要,需要创建数百个用户,手动创建当然不可取,此时需要批量创建,操作记录如下 1 首先将要批量创建的人员信息导入到一个csv文件中,表中 ...

  9. 2014 Super Training #8 A Gears --并查集

    题意: 有N个齿轮,三种操作1.操作L x y:把齿轮x,y链接,若x,y已经属于某个齿轮组中,则这两组也会合并.2.操作Q x y:询问x,y旋转方向是否相同(等价于齿轮x,y的相对距离的奇偶性). ...

  10. HDU 1556 Color the ball

    这题用线段树的话简直就是一个水题..不过刚学树状数组,要用一下. 题意:每次给你a,b,表明a~b之间涂色,然后最后一次输出每个气球被涂色的次数. 要用树状数组就要考虑怎么转化为前缀和问题,这题可以这 ...