剑指offer
丑数
相似的企业真题
时间限制:C/C++ 1秒,其他语言2秒
空间限制:C/C++ 64M,其他语言128M
热度指数:515083
本题知识点:
数学
二分
算法知识视频讲解
校招时部分企业笔试将禁止编程题跳出页面,为提前适应,练习时请使用在线自测,而非本地IDE。
题目描述
把只包含质因子2、3和5的数称作丑数(Ugly Number)。例如6、8都是丑数,但14不是,因为它包含质因子7。 习惯上我们把1当做是第一个丑数。求按从小到大的顺序的第N个丑数。
示例1
输入
复制
7
7
返回值
复制
8
8
上一题
下一题
登录
/
注册
我的提交
编辑器加载中...
public class Solution { public int GetUglyNumber_Solution(int index) { return 0; } }
class Solution { public: int GetUglyNumber_Solution(int index) { } };
# -*- coding:utf-8 -*- class Solution: def GetUglyNumber_Solution(self, index): # write code here
class Solution { public int GetUglyNumber_Solution(int index) { // write code here } }
function GetUglyNumber_Solution(index) { // write code here } module.exports = { GetUglyNumber_Solution : GetUglyNumber_Solution };
function GetUglyNumber_Solution(index) { // write code here }
# -*- coding:utf-8 -*- class Solution: def GetUglyNumber_Solution(self, index): # write code here
package main /** * * @param index int整型 * @return int整型 */ func GetUglyNumber_Solution( index int ) int { // write code here }
/** * * @param index int整型 * @return int整型 */ int GetUglyNumber_Solution(int index ) { // write code here }
# # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # @param index int整型 # @return int整型 # class Solution def GetUglyNumber_Solution(index) # write code here end end
object Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * @param index int整型 * @return int整型 */ def GetUglyNumber_Solution(index: Int): Int = { // write code here } }
object Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * @param index int整型 * @return int整型 */ fun GetUglyNumber_Solution(index: Int): Int { // write code here } }
import java.util.*; public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * @param index int整型 * @return int整型 */ public int GetUglyNumber_Solution (int index) { // write code here } }
/** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * @param index int整型 * @return int整型 */ export function GetUglyNumber_Solution(index: number): number { // write code here }
public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * @param index int整型 * @return int整型 */ func GetUglyNumber_Solution ( _ index: Int) -> Int { // write code here } }
struct Solution{ } impl Solution { fn new() -> Self { Solution{} } /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * @param index int整型 * @return int整型 */ pub fn GetUglyNumber_Solution(&self, index: i32) -> i32 { // write code here } }
7
8