题目链接:http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1105

题意:中文题诶~

思路:直接二分答案,再通过二分找有多少组合大于等于当前值,确定答案;

代码:

 #include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#define ll long long
using namespace std; const int MAXN=1e5;
ll a[MAXN], b[MAXN]; ll is_ok(ll mid, ll n){
ll ans=;
for(int i=; i<n; i++){
// ll cnt=ceil(mid*1.0/a[i]);//***这里用ceil会wa,坑死,可能是double转long long有误差
ll cnt=mid/a[i];
if(mid%a[i]) cnt+=;
int pos=lower_bound(b, b+n, cnt)-b;
ans+=n-pos;
}
return ans;
} int main(void){
ll n, k;
scanf("%lld%lld", &n, &k);
for(int i=; i<n; i++){
scanf("%lld%lld", &a[i], &b[i]);
}
sort(a, a+n);
sort(b, b+n);
ll l=a[]*b[], r=a[n-]*b[n-];
while(l<=r){
ll mid=(l+r)>>;
ll cnt=is_ok(mid, n);
if(cnt>=k) l=mid+;
else r=mid-;
}
cout << l- << endl;
return ;
}

51nod1105(二分)的更多相关文章

  1. [51NOD1105]第k大的数(二分答案)

    题目链接:http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1105 先排序,二分上下界分别是最小的两个数和最大的两个数的乘积 ...

  2. BZOJ1012: [JSOI2008]最大数maxnumber [线段树 | 单调栈+二分]

    1012: [JSOI2008]最大数maxnumber Time Limit: 3 Sec  Memory Limit: 162 MBSubmit: 8748  Solved: 3835[Submi ...

  3. BZOJ 2756: [SCOI2012]奇怪的游戏 [最大流 二分]

    2756: [SCOI2012]奇怪的游戏 Time Limit: 40 Sec  Memory Limit: 128 MBSubmit: 3352  Solved: 919[Submit][Stat ...

  4. 整体二分QAQ

    POJ 2104 K-th Number 时空隧道 题意: 给出一个序列,每次查询区间第k小 分析: 整体二分入门题? 代码: #include<algorithm> #include&l ...

  5. [bzoj2653][middle] (二分 + 主席树)

    Description 一个长度为n的序列a,设其排过序之后为b,其中位数定义为b[n/2],其中a,b从0开始标号,除法取下整. 给你一个长度为n的序列s. 回答Q个这样的询问:s的左端点在[a,b ...

  6. [LeetCode] Closest Binary Search Tree Value II 最近的二分搜索树的值之二

    Given a non-empty binary search tree and a target value, find k values in the BST that are closest t ...

  7. [LeetCode] Closest Binary Search Tree Value 最近的二分搜索树的值

    Given a non-empty binary search tree and a target value, find the value in the BST that is closest t ...

  8. jvascript 顺序查找和二分查找法

    第一种:顺序查找法 中心思想:和数组中的值逐个比对! /* * 参数说明: * array:传入数组 * findVal:传入需要查找的数 */ function Orderseach(array,f ...

  9. BZOJ 1305: [CQOI2009]dance跳舞 二分+最大流

    1305: [CQOI2009]dance跳舞 Description 一次舞会有n个男孩和n个女孩.每首曲子开始时,所有男孩和女孩恰好配成n对跳交谊舞.每个男孩都不会和同一个女孩跳两首(或更多)舞曲 ...

随机推荐

  1. 20170325 ABAP调用webservice

    转自:http://www.cnblogs.com/SolisOculus/archive/2013/04/01/2993198.html 在ABAP中调用Webservice     1.创建Pro ...

  2. HTML——列表的相关知识

    核心知识点: 1.无序列表: ul>li 2.有序列表:ol>li 3.标题列表:dl(标签)>dt(标题)>dd(选项) 4.表格:table>thead(>tr ...

  3. linux内核 RCU机制详解【转】

    本文转载自:https://blog.csdn.net/xabc3000/article/details/15335131 简介 RCU(Read-Copy Update)是数据同步的一种方式,在当前 ...

  4. 配置 git 以ssh公钥访问github

    #生成ssh config touch .ssh/config chmod 600 config 填写: Host github.com User betachen Hostname ssh.gith ...

  5. 分享知识-快乐自己:java 中的访问修饰符

    1):Java中的访问修饰符: Java面向对象的基本思想之一是封装细节并且公开接口.Java语言采用访问控制修饰符来控制类及类的方法和变量的访问权限,从而向使用者暴露接口,但隐藏实现细节. 访问控制 ...

  6. C++ string的查找函数和npos特殊值

    STL中的string有6个查找函数: 1.find() 2.rfind() 从最后一个字符开始往前找. 3.find_first_of() 4.find_not_first_of() 5.find_ ...

  7. PS 滤镜— — 万花筒效果

    clc; clear all; close all; addpath('E:\PhotoShop Algortihm\Image Processing\PS Algorithm'); I=imread ...

  8. 【LeetCode】Maximum Product Subarray 求连续子数组使其乘积最大

    Add Date 2014-09-23 Maximum Product Subarray Find the contiguous subarray within an array (containin ...

  9. Stop logging "internal dummy connection" in Apache

    Apache 2.x keeps child processes alive by creating internal connections which appear in the log file ...

  10. Codeforces Round #394 (Div. 2) 题解

    无需吟唱,直接传送 problem A 题目大意 已知有n个偶数,m个奇数,问这些数有没有可能组成一个严格递增1的序列 题解 判断abs(n,m) <= 1即可,注意n,m均为0的情况. Cod ...