Description

Inhabitants of the Wonderland have decided to hold a regional programming contest. The Judging Committee has volunteered and has promised to organize the most honest contest ever. It was decided to connect computers for the contestants using a "star" topology - i.e. connect them all to a single central hub. To organize a truly honest contest, the Head of the Judging Committee has decreed to place all contestants evenly around the hub on an equal distance from it. 
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

The first line of the input file contains two integer numb ers N and K, separated by a space. N (1 = N = 10000) is the number of cables in the stock, and K (1 = K = 10000) is the number of requested pieces. The first line is followed by N lines with one number per line, that specify the length of each cable in the stock in meters. All cables are at least 1 meter and at most 100 kilometers in length. All lengths in the input file are written with a centimeter precision, with exactly two digits after a decimal point.

Output

Write to the output file the maximal length (in meters) of the pieces that Cable Master may cut from the cables in the stock to get the requested number of pieces. The number must be written with a centimeter precision, with exactly two digits after a decimal point. 
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

Northeastern Europe 2001
 
 
二分答案,做着玩玩。
感觉乘100变成int64搞好一点,我用的double,细节太多,WA无数次。
主要细节是输出的时候不能四舍五入,要直接把小数点后3位之后截掉,因为比如能0.0099,但四舍五入就成了0.01,而实际上是0.00。用int64应该就没有这个问题。
判断函数名一般用什么啊,蒟蒻表示没经验只好用自己喜欢的球星库里了。(要是有有经验的神犇记得留言啊)
 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的更多相关文章

  1. 二分法的应用:POJ1064 Cable master

    /* POJ1064 Cable master 时间限制: 1000MS 内存限制: 10000K 提交总数: 58217 接受: 12146 描述 Wonderland的居民已经决定举办地区性编程比 ...

  2. poj1064 Cable master(二分)

    Cable master 求电缆的最大长度(二分法)   Description Inhabitants of the Wonderland have decided to hold a region ...

  3. poj1064 Cable master(二分查找,精度)

    https://vjudge.net/problem/POJ-1064 二分就相当于不停地折半试. C++AC,G++WA不知为何,有人说C函数ans那里爆int了,改了之后也没什么用. #inclu ...

  4. POJ1064 Cable master 【二分找最大值】

    题目:题目太长了! https://vjudge.net/problem/POJ-1064 题意分析:给了你N根长度为小数形式的棍子,再给出了你需要分的棍子的数量K,但要求你这K根棍子的长度必须是一样 ...

  5. POJ1064 Cable master(二分 浮点误差)

    题目链接:传送门 题目大意: 给出n根长度为1-1e5的电线,想要从中切割出k段等长的部分(不可拼接),问这个k段等长的电线最长可以是多长(保留两位小数向下取整). 思路: 很裸的题意,二分答案即可. ...

  6. 【POJ - 1064】Cable master(二分)

    Cable master Descriptions 输入2个数 N  K n条绳子    要分成大于等于k段 求每段最长多长呢?并且每段不能小于1cm 必须以厘米精度写入数字,小数点后正好是两位数.如 ...

  7. POJ 1064 Cable master (二分)

    题目链接: 传送门 Cable master Time Limit: 1000MS     Memory Limit: 65536K 题目描述 有N条绳子,它们长度分别为Li.如果从它们中切割出K条长 ...

  8. [ACM] poj 1064 Cable master (二分查找)

    Cable master Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 21071   Accepted: 4542 Des ...

  9. Cable master(二分题 注意精度)

    Cable master Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 26596   Accepted: 5673 Des ...

随机推荐

  1. 翻译 | The Principles of OOD 面向对象设计原则

    本文首发于vivo互联网技术微信公众号 https://mp.weixin.qq.com/s/Q_pziBUhKRywafKeY2T7YQ 作者:Robert C. Martin 翻译:张硕 本文由来 ...

  2. 20155313 杨瀚 《网络对抗技术》实验九 Web安全基础

    20155313 杨瀚 <网络对抗技术>实验九 Web安全基础 一.实验目的 本实践的目标理解常用网络攻击技术的基本原理.Webgoat实践下相关实验. 二.基础问题回答 1.SQL注入攻 ...

  3. 总结:C# 委托的全面理解

    在说事件之前得先了解委托. 委托,外表看来和C/C++中函数指针没什么区别,但是本质上你才发现他其实就是个类!也就是说理解委托得从 这个两个方面去理解(单从一个方面去理解感觉就怪怪的呵呵!) 理解委托 ...

  4. 阿里云代金券 - 双12疯了~~~ 4核8G 3M带宽只要1890元/3年

    阿里云双12大促简直疯了,4核8G 3M带宽只要1890元/3年,比双11疯狂多了,双11没有上车的赶快来买吧!!! 前去阿里云双12活动页面 截图如下: 从截图中可以看出,不仅4核8G降到了地板,1 ...

  5. C++中前置声明介绍

    前置声明是指对类.函数.模板或者结构体进行声明,仅仅是声明,不包含相关具体的定义.在很多场合我们可以用前置声明来代替#include语句. 类的前置声明只是告诉编译器这是一个类型,但无法告知类型的大小 ...

  6. [JOI2017春季合宿]Port Facility[set、二分图]

    题意 你有两个栈,有 \(n\) 个货物,每个货物有一个进栈时间和出栈时间(所有时间的并集是1~2n),问有多少种不同的入栈方案. \(n\le 10^6\) 分析 把每个货物的存在看成区间,相交的区 ...

  7. [BZOJ4842]Delight for a Cat[费用流]

    题意 题目链接 分析 类似 最长k可重区间集 一题. 由于本题区间长度相同,首先可以将点的影响看成区间,区间看成点. 先默认所有位置选择事件2,选择区间看做改选事件1 .于是问题变成了求收益最大的方案 ...

  8. 小知识点--crontab

    前言 这两周学了很多东西,还把golang语言基本掌握了,收获还是挺多的.在做安全的过程中,有很多需要定时执行的任务,比如抓取主机数量,端口数据等,这都逃不开linux中的crontab命令,今天分享 ...

  9. Unity光照与渲染设置学习笔记

    学习了一下unity中有关光照和渲染的一些设置,现在才明白之前遇到的一些问题只是没有正确设置而已. unity不同版本的光照设置会有一些差异,而且可以调节的参数非常多,这里只记录一些重要的参数和使用方 ...

  10. java第二次实验报告

    课程:Java实验   班级:201352     姓名:池彬宁  学号:20135212 成绩:             指导教师:娄佳鹏   实验日期:15.05.05 实验密级:         ...