poj1064 Cable master
Description
To buy network cables, the Judging Committee has contacted a local network solutions provider with a request to sell for them a specified number of cables with equal lengths. The Judging Committee wants the cables to be as long as possible to sit contestants as far from each other as possible.
The Cable Master of the company was assigned to the task. He knows the length of each cable in the stock up to a centimeter,and he can cut them with a centimeter precision being told the length of the pieces he must cut. However, this time, the length is not known and the Cable Master is completely puzzled.
You are to help the Cable Master, by writing a program that will determine the maximal possible length of a cable piece that can be cut from the cables in the stock, to get the specified number of pieces.
Input
Output
If it is not possible to cut the requested number of pieces each one being at least one centimeter long, then the output file must contain the single number "0.00" (without quotes).
Sample Input
4 11
8.02
7.43
4.57
5.39
Sample Output
2.00
Source
program rrr(input,output);
const
eps=0.000001;
var
a:array[..]of double;
n,i:longint;
k,cnt:int64;
l,r,mid:double;
function curry(x:double):boolean;
begin
cnt:=;
for i:= to n do begin cnt:=cnt+trunc(a[i]/x);if cnt>=k then exit(true); end;
exit(false);
end;
begin
assign(input,'r.in');assign(output,'r.out');reset(input);rewrite(output);
readln(n,k);r:=;
for i:= to n do begin readln(a[i]);if a[i]>r then r:=a[i]; end;
l:=;
while r-l>eps do
begin
mid:=(l+r)/;
if curry(mid) then l:=mid else r:=mid;
end;
write(trunc(r*)/::);
close(input);close(output);
end.
poj1064 Cable master的更多相关文章
- 二分法的应用:POJ1064 Cable master
/* POJ1064 Cable master 时间限制: 1000MS 内存限制: 10000K 提交总数: 58217 接受: 12146 描述 Wonderland的居民已经决定举办地区性编程比 ...
- poj1064 Cable master(二分)
Cable master 求电缆的最大长度(二分法) Description Inhabitants of the Wonderland have decided to hold a region ...
- poj1064 Cable master(二分查找,精度)
https://vjudge.net/problem/POJ-1064 二分就相当于不停地折半试. C++AC,G++WA不知为何,有人说C函数ans那里爆int了,改了之后也没什么用. #inclu ...
- POJ1064 Cable master 【二分找最大值】
题目:题目太长了! https://vjudge.net/problem/POJ-1064 题意分析:给了你N根长度为小数形式的棍子,再给出了你需要分的棍子的数量K,但要求你这K根棍子的长度必须是一样 ...
- POJ1064 Cable master(二分 浮点误差)
题目链接:传送门 题目大意: 给出n根长度为1-1e5的电线,想要从中切割出k段等长的部分(不可拼接),问这个k段等长的电线最长可以是多长(保留两位小数向下取整). 思路: 很裸的题意,二分答案即可. ...
- 【POJ - 1064】Cable master(二分)
Cable master Descriptions 输入2个数 N K n条绳子 要分成大于等于k段 求每段最长多长呢?并且每段不能小于1cm 必须以厘米精度写入数字,小数点后正好是两位数.如 ...
- POJ 1064 Cable master (二分)
题目链接: 传送门 Cable master Time Limit: 1000MS Memory Limit: 65536K 题目描述 有N条绳子,它们长度分别为Li.如果从它们中切割出K条长 ...
- [ACM] poj 1064 Cable master (二分查找)
Cable master Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 21071 Accepted: 4542 Des ...
- Cable master(二分题 注意精度)
Cable master Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 26596 Accepted: 5673 Des ...
随机推荐
- 翻译 | The Principles of OOD 面向对象设计原则
本文首发于vivo互联网技术微信公众号 https://mp.weixin.qq.com/s/Q_pziBUhKRywafKeY2T7YQ 作者:Robert C. Martin 翻译:张硕 本文由来 ...
- 20155313 杨瀚 《网络对抗技术》实验九 Web安全基础
20155313 杨瀚 <网络对抗技术>实验九 Web安全基础 一.实验目的 本实践的目标理解常用网络攻击技术的基本原理.Webgoat实践下相关实验. 二.基础问题回答 1.SQL注入攻 ...
- 总结:C# 委托的全面理解
在说事件之前得先了解委托. 委托,外表看来和C/C++中函数指针没什么区别,但是本质上你才发现他其实就是个类!也就是说理解委托得从 这个两个方面去理解(单从一个方面去理解感觉就怪怪的呵呵!) 理解委托 ...
- 阿里云代金券 - 双12疯了~~~ 4核8G 3M带宽只要1890元/3年
阿里云双12大促简直疯了,4核8G 3M带宽只要1890元/3年,比双11疯狂多了,双11没有上车的赶快来买吧!!! 前去阿里云双12活动页面 截图如下: 从截图中可以看出,不仅4核8G降到了地板,1 ...
- C++中前置声明介绍
前置声明是指对类.函数.模板或者结构体进行声明,仅仅是声明,不包含相关具体的定义.在很多场合我们可以用前置声明来代替#include语句. 类的前置声明只是告诉编译器这是一个类型,但无法告知类型的大小 ...
- [JOI2017春季合宿]Port Facility[set、二分图]
题意 你有两个栈,有 \(n\) 个货物,每个货物有一个进栈时间和出栈时间(所有时间的并集是1~2n),问有多少种不同的入栈方案. \(n\le 10^6\) 分析 把每个货物的存在看成区间,相交的区 ...
- [BZOJ4842]Delight for a Cat[费用流]
题意 题目链接 分析 类似 最长k可重区间集 一题. 由于本题区间长度相同,首先可以将点的影响看成区间,区间看成点. 先默认所有位置选择事件2,选择区间看做改选事件1 .于是问题变成了求收益最大的方案 ...
- 小知识点--crontab
前言 这两周学了很多东西,还把golang语言基本掌握了,收获还是挺多的.在做安全的过程中,有很多需要定时执行的任务,比如抓取主机数量,端口数据等,这都逃不开linux中的crontab命令,今天分享 ...
- Unity光照与渲染设置学习笔记
学习了一下unity中有关光照和渲染的一些设置,现在才明白之前遇到的一些问题只是没有正确设置而已. unity不同版本的光照设置会有一些差异,而且可以调节的参数非常多,这里只记录一些重要的参数和使用方 ...
- java第二次实验报告
课程:Java实验 班级:201352 姓名:池彬宁 学号:20135212 成绩: 指导教师:娄佳鹏 实验日期:15.05.05 实验密级: ...