题目链接: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. .htaccess技巧: URL重写(Rewrite)与重定向(Redirect) (转)

    目录 Table of Contents 一.准备开始:mod_rewrite 二.利用.htaccess实现URL重写(rewrite)与URL重定向(redirect) 将.htm页面映射到.ph ...

  2. 采集练习(十一) php 获得电视节目预告---数据来自电视猫

    昨天写了个采集搜视网的电视节目预告,刚好今天有心情,想采下其他网站提供的节目预告,发现  电视猫wap版 的提供的节目预告也蛮好采(需要正则)....感谢移动互联网! 电视猫的 wap版地址是 htt ...

  3. 【shell】shuf命令,随机排序

    shuf命令主要用来对输入的每一行进行随机排序输出,我们可以利用这个属性,实现在几个文件中随机读取一个的功能 如下,zls.txt文件有三行,我们想要随机从中读取一行. 可以看到,每次读取顺序都不一样 ...

  4. weblogic开启远程访问的jmx设置

    通过jmx远程访问weblogic获取监控jvm的数据,要在weblogic启动的时候设置一些配置,具体如下: 在weblogic的安装目录:{weblogic_home}/wlserver_10.3 ...

  5. before-request , after-request

    1 . flask的中间件 1)@app.before_request     # 请求进入视图函数之前,类似于django中间件的request_process 2)@app.after_reque ...

  6. Algorithm: dynamic programming

    1. Longest Increasing Subsequence (LIS) problem unsorted array, calculate out the maximum length of ...

  7. javscript 一些常用的工具方法

    一些工作中经常会用到的js代码,可以封装成一个工具库. 积少成多,从现在开始吧! -------------- 1 . 判断一段文字的长度.要求中文相当于2个字符,非中文的相当于1个字符 String ...

  8. BZOJ 3410 [Usaco2009 Dec]Selfish Grazing 自私的食草者:贪心【最多线段覆盖】

    题目链接:http://begin.lydsy.com/JudgeOnline/problem.php?id=1324 题意: 给你n个区间,问你最多能选择多少个区间使得它们不相互覆盖. 题解: RQ ...

  9. String类中的equals是如何重写的

    我们知道String中的equals方法是被重写过的,因为object的equals方法是比较的对象的内存地址,而String的equals方法比较的是对象的值. 首先几个知识点: 基本数据类型==比 ...

  10. L91

    Make Healthy Choices Easier Options Telling people to change unhealthy behaviors doesn't work. Other ...