D. Multiplication Table 二分查找
刚做这道题根本没想到二分,最关键是没想出来怎样统计在这个矩阵中比一个数小的有几个怎么算。造成自己想了好久最后看了别人的提示才做出来。哎。好久不做题太弱了
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
// freopen("in.txt","r",stdin);
long long n,m,k;
while(cin>>n>>m>>k){
long long r=n*m,l=1,ans;
while(r>l){
long long mid=(r+l)/2;
long long t=0;
for(int i=1;i<=n;i++){//统计在这个矩阵中比一个数小的有几个
t+=min(m,mid/i);
}
if(t>=k) r=mid;
if(t<k) l=mid+1; }
cout<<r<<endl;
}
}
D. Multiplication Table 二分查找的更多相关文章
- Codeforces 448 D. Multiplication Table 二分
题目链接:D. Multiplication Table 题意: 给出N×M的乘法矩阵要你求在这个惩罚矩阵中第k个小的元素(1 ≤ n, m ≤ 5·10^5; 1 ≤ k ≤ n·m). 题解: n ...
- cf448D Multiplication Table 二分
题目:http://codeforces.com/problemset/problem/448/D 题意:给出n,m,k,即在一个n*m的二维数组中找第k大的数,第i行第j列的数的值为i*j. 思路: ...
- LeetCode hard 668. Kth Smallest Number in Multiplication Table(二分答案,一次过了,好开心,哈哈哈哈)
题目:https://leetcode.com/problems/kth-smallest-number-in-multiplication-table/description/ 668. Kth S ...
- 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 ...
- [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 ...
- cf448D Multiplication Table
D. Multiplication Table time limit per test 1 second memory limit per test 256 megabytes input stand ...
- Codeforces Round #256 (Div. 2) D. Multiplication Table(二进制搜索)
转载请注明出处:viewmode=contents" target="_blank">http://blog.csdn.net/u012860063?viewmod ...
- 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 ...
- python开发学习-day04(迭代器、生成器、装饰器、二分查找、正则)
s12-20160123-day04 *:first-child { margin-top: 0 !important; } body>*:last-child { margin-bottom: ...
随机推荐
- IE版本的判断
var Sys = {};var ua = navigator.userAgent.toLowerCase(); var s;(s = ua.match(/msie ([\d.]+)/)) ? Sys ...
- 【LeetCode】-- 73. Set Matrix Zeroes
问题描述:将二维数组中值为0的元素,所在行或者列全set为0:https://leetcode.com/problems/set-matrix-zeroes/ 问题分析:题中要求用 constant ...
- JQuery 记第N次被坑 - ajax请求字符集问题
前言:两个功能差不多的页面,都是使用$.post()请求后台,页面A传递到后台的中文参数正常,页面B传递到后台的中文参数则为乱码 分析过程: ①使用chrome的开发者工具,分析两个页面的ajax请求 ...
- Xml的读取
using System; using System.Collections.Generic; using System.Linq; using System.Web; namespace WebAp ...
- html5+css3杂记
H5C3个人笔记 before&after 1. 必须有content display 2. 场景:不想改变html结构:解决浮动 解决浮动: 2c d h v transition 过渡 1 ...
- activiti 表——介绍
Activiti 用到的表都是act_开头 下面分别来介绍下 activiti 所用到的表: Act_RE_* 表示 RepositoryService接口所操作的表:包含了流程定义信息 .流程静态资 ...
- [转]Linux下/proc目录简介
1. /proc目录Linux 内核提供了一种通过 /proc 文件系统,在运行时访问内核内部数据结构.改变内核设置的机制.proc文件系统是一个伪文件系统,它只存在内存当中,而不占用外存空间.它以文 ...
- 【译】x86程序员手册13-第5章 内存管理
Chapter 5 Memory Management 内存管理 The 80386 transforms logical addresses (i.e., addresses as viewed b ...
- javascript常用功能函数
特殊字符转义:将<, >, &, “进行转义 function escape(str){ return str.replace(/[<>"&]/g,f ...
- transactoin
hibernate对数据的操作是封装在事务当中,并且默认是非自动提交方式.所以用session保存对象时,如果不开启事务,并且手工提交事务,对象并不会真正保存在数据库中.