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. CentOS6.5下RPM方式安装mysql5.6.33

    1.mysql下载 下载地址:https://dev.mysql.com/downloads/mysql/5.6.html下载以下安装包: MySQL-client-5.6.33-1.el6.x86_ ...

  2. Monyer's Game 6~10关过关方法

    从Monyer's Game开通到现在,已经有50多人通关了.其中绝大部分人,不管是自己独立完成也好,参考别人也罢,都是自己一步一步过去的.像陆羽兄弟甚至已经为游戏做好了整个通关的教程,在此Monye ...

  3. [ASP.NET MVC]: - EF框架学习手记

    1.EF(Entity Framework)实体框架EF是ADO.NET中的一组支持开发面向数据的软件应用程序的技术,是微软的一个ORM框架. 2.什么是ORM?ORM指的是面向对象的对象模型和关系型 ...

  4. IO流01--毕向东JAVA基础教程视频学习笔记

    提要 01 IO流(BufferedWriter)02 IO流(BufferedReader)03 IO流(通过缓冲区复制文本文件)04 IO流(readLine的原理)05 IO流(MyBuffer ...

  5. C#输入输出重定向

    当 Process 将文本写入其标准流中时,通常将在控制台上显示该文本.通过重定向 StandardOutput 流,可以操作或取消进程的输出.例如,可以筛选文本.用不同方式将其格式化,也可以将输出同 ...

  6. Effective Java 23 Don't use raw types in new code

    Generic types advantage Parameterized type can provide erroneous check in compile time. // Parameter ...

  7. JavaScript Patterns 4.2 Callback Pattern

    function writeCode(callback) { // do something... callback(); // ... } function introduceBugs() { // ...

  8. Python2

    安装pycharm专业版,不要汉化 要想写的代码支持linux和2.0版本需要在开头加上注释 #/usr/bin/env python #-*- coding:utf-8 -*- 运算符 结果是值 算 ...

  9. db2 常用命令(一)

    DB2数据库常用命令小结   ========操作数据库命令==========   -- 启动数据库实例 #db2start    -- 停止数据库实例    #db2sto         # 如 ...

  10. oracle11G在linux环境下的卸载操作

    1.使用SQL*PLUS停止数据库[oracle@OracleTest oracle]$ sqlplus logSQL> connect / as sysdbaSQL> shutdown ...