题目:http://codeforces.com/problemset/problem/448/D

题意:给出n,m,k,即在一个n*m的二维数组中找第k大的数,第i行第j列的数的值为i*j。

思路:二分答案,每一行中找比它小的数之和(单调函数),作为check的条件来转移。

#include<bits/stdc++.h>
using namespace std;
int n,m;
long long k;
bool check(long long mid)
{
long long res=;
for(int i=;i<=n;i++)
{
res+=min(mid/i,1ll*m);
}
if(res>=k)return ;
return ;
}
int main()
{
scanf("%d%d%lld",&n,&m,&k);
long long l=,r=1ll*n*m,ans=-;
while(l<=r)
{
long long mid=l+r>>;
if(check(mid))
{
ans=mid;
r=mid-;
}
else l=mid+;
}
printf("%lld\n",ans);
return ;
}

cf448D Multiplication Table 二分的更多相关文章

  1. 洛谷 CF448D Multiplication Table

    目录 题目 思路 \(Code\) 题目 CF448D Multiplication Table 思路 二分答案.这个矩阵的每一排都是递增的,所以二分\(ans\),去计算有多少个数等于\(ans\) ...

  2. cf448D Multiplication Table

    D. Multiplication Table time limit per test 1 second memory limit per test 256 megabytes input stand ...

  3. Codeforces 448 D. Multiplication Table 二分

    题目链接:D. Multiplication Table 题意: 给出N×M的乘法矩阵要你求在这个惩罚矩阵中第k个小的元素(1 ≤ n, m ≤ 5·10^5; 1 ≤ k ≤ n·m). 题解: n ...

  4. D. Multiplication Table 二分查找

    刚做这道题根本没想到二分,最关键是没想出来怎样统计在这个矩阵中比一个数小的有几个怎么算.造成自己想了好久最后看了别人的提示才做出来.哎.好久不做题太弱了 #include<iostream> ...

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

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

  6. Codeforces Round #256 (Div. 2) D. Multiplication Table 很有想法的一个二分

    D. Multiplication Table time limit per test 1 second memory limit per test 256 megabytes input stand ...

  7. Codeforces Round #256 (Div. 2) D. Multiplication Table 二分法

     D. Multiplication Table time limit per test 1 second memory limit per test 256 megabytes input st ...

  8. [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 ...

  9. Day8 - D - Multiplication Table CodeForces - 448D

    Bizon the Champion isn't just charming, he also is very smart. While some of us were learning the mu ...

随机推荐

  1. PHP Notice: Undefined index:解决方法

    PHP Notice:  Undefined index:解决方法 PHP Notice: Undefined index: 解决方法 <pre> if (empty(swoole_get ...

  2. jquery判断手指滑动方向

    jquery判断手指滑动方向 <pre> /*判断哪个滑动方向还是自己改下 要么上下 要么左右*/ var startX; var startY; $(".shanghua&qu ...

  3. jquery鼠标点击穿透的解决方法

    jquery鼠标点击穿透的解决方法 <pre><div class="showcontainer" style="background:#000;dis ...

  4. Linux下rpm仓库搭建

    一.概念 1.rpm是什么?在帮助文档里我们可以看到,rpm的名字是rpm package manage 的缩写, 从名字上看就可以知道rpm就是一个包管理工具.简单说rpm包就是把一些程序编译成二进 ...

  5. 《计算机网络 自顶向下方法》 第8章 计算机网络中的安全 Part2

    SSL(使 TCP 连接安全) SSL(Secure Socket Layer),即安全套接字层,是对 TCP 的强化 HTTPS 使用 SSL,而 HTTP 不使用 SSL 通过采用机密性.数据完整 ...

  6. Python Excel 绘制柱形图

    本文主要讲述如何使用Python操作Excel绘制柱形图. 相关代码请参考 https://github.com/RustFisher/python-playground 本文链接:https://w ...

  7. nyoj 27-水池数目(BFS, DFS)

    27-水池数目 内存限制:64MB 时间限制:3000ms Special Judge: No accepted:17 submit:22 题目描述: 南阳理工学院校园里有一些小河和一些湖泊,现在,我 ...

  8. JavaWeb02-Servlet

    Servlet概述 生命周期方法: l  void init(ServletConfig):出生之后(1次): l  void service(ServletRequest request, Serv ...

  9. 万恶之源-python加深

    1.列表 1.1列表的含义: ​ 它是以[]括起来,每个元素用""引起来,用逗号隔开而且可以存放各种类型的数据. li=["樊大爷",王立军",&qu ...

  10. python3 之 内置函数range()

    一.语法: range(stop) range(start,stop,step) start:计数从start开始,默认是从0开始.eg:range(5)等价于range(0,5) stop:计数到s ...