题目如下:

解题思路:几乎和【leetcode】719. Find K-th Smallest Pair Distance 的方法一样。只不过一个是减法一个是乘法,还有一点区别是【leetcode】719. Find K-th Smallest Pair Distance中i-j和j-i只算一个元素,而本题中i*j与j*i算两个元素。

代码如下:

class Solution(object):
def findKthNumber(self, m, n, k):
"""
:type m: int
:type n: int
:type k: int
:rtype: int
"""
low,high = 1, m*n while low <= high:
mid = (low + high) / 2
less,equal = 0,0
for i in range(1,min(mid+1,m+1)):
less += min(mid/i,n)
if mid/i <= n and mid % i == 0:
equal += 1
less -= 1 if less >= k:
high = mid - 1
elif less + equal < k:
low = mid + 1
elif less == k and equal == 0:
high = mid - 1
else:
break
return mid

【leetcode】668. Kth Smallest Number in Multiplication Table的更多相关文章

  1. LeetCode hard 668. Kth Smallest Number in Multiplication Table(二分答案,一次过了,好开心,哈哈哈哈)

    题目:https://leetcode.com/problems/kth-smallest-number-in-multiplication-table/description/ 668. Kth S ...

  2. 668. Kth Smallest Number in Multiplication Table

    Nearly every one have used the Multiplication Table. But could you find out the k-th smallest number ...

  3. 【LeetCode】378. Kth Smallest Element in a Sorted Matrix 解题报告(Python)

    [LeetCode]378. Kth Smallest Element in a Sorted Matrix 解题报告(Python) 标签: LeetCode 题目地址:https://leetco ...

  4. [LeetCode] Kth Smallest Number in Multiplication Table 乘法表中的第K小的数字

    Nearly every one have used the Multiplication Table. But could you find out the k-th smallest number ...

  5. [Swift]LeetCode668. 乘法表中第k小的数 | Kth Smallest Number in Multiplication Table

    Nearly every one have used the Multiplication Table. But could you find out the k-th smallest number ...

  6. 【LeetCode】230. Kth Smallest Element in a BST

    Difficulty: Medium  More:[目录]LeetCode Java实现 Description https://leetcode.com/problems/kth-smallest- ...

  7. 【leetcode】378. Kth Smallest Element in a Sorted Matrix(TOP k 问题)

    Given an n x n matrix where each of the rows and columns is sorted in ascending order, return the kt ...

  8. 【Leetcode】378. Kth Smallest Element in a Sorted Matrix

    Question: Given a n x n matrix where each of the rows and columns are sorted in ascending order, fin ...

  9. 【LeetCode】230. Kth Smallest Element in a BST (2 solutions)

    Kth Smallest Element in a BST Given a binary search tree, write a function kthSmallest to find the k ...

随机推荐

  1. php的URL查询字符串解析函数

    URL查询字符串格式:Data[650][BLN]=40002307312&Data[650][Status]=電聯無人接聽. 解析这种数据使用函数:parse_str(). parse_st ...

  2. DVBS/S2功能

  3. win2016

    slmgr /ipk CB7KF-BWN84-R7R2Y-793K2-8XDDG slmgr /skms kms.03k.org slmgr /ato

  4. 【学习总结】Python-3-字符串函数split()的妙用

    参考: 菜鸟教程-Python3-Python字符串-split() 语法: str.split(str="", num=string.count(str)) 参数 str -- ...

  5. CSS-02 BFC的理解

    两个概念 感觉BFC挺重要的,于是最近查阅网上资料后小结一下,如果有不对的地方还望指正. 先理解两个概念: BOX :盒子模型 Block-Leave Box :块级元素 display属性为bloc ...

  6. 【知识强化】第五章 中央处理器 5.1 CPU的功能和基本结构

    那么在前四章我们已经把数据的表示和运算,存储系统和指令系统都已经给大家讲完了.那么从这一章开始,我们将要讲解中央处理器的内容.那么这一部分内容我们就进入到我们计算机组成原理的一个深水区,它是我们计算机 ...

  7. centos7 利用mailx发送邮件

    当需要服务器定时发送邮件到自己邮箱时,一个邮件服务就很重要了,以下主要是mailx的实现,主要是利用 1.安装mailx 1 yum  install  mailx -y 2.使用到的配置文件只有一个 ...

  8. linux改变内核参数

  9. MyEclipse创建maven项目时报: org.apache.maven.archiver.MavenArchiver.getManifest 错误

    创建项目报错,如图: 原因就是maven的配置文件不是最新的,MyEclipse2014解决方法: 1.help ->Install New sitie... 2.点击add 3.填写name和 ...

  10. Kintex7 XC7K325T 板卡三剑客

    (226)基于Xilinx Kintex-7 FPGA K7 XC7K325T PCIeX8 四路光纤卡   (227)基于Xilinx Kintex-7 FPGA K7 XC7K325T的FMC U ...