Cable master

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 2499    Accepted Submission(s):
936

Problem 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 input consists of several testcases. The first line
of each testcase contains two integer numbers 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 centimeter and at most 100 kilometers in length. All
lengths in the input are written with a centimeter precision, with exactly two
digits after a decimal point.

The input is ended by line containing two
0's.

 
Output
For each testcase write to the output 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 must contain the single number "0.00"
(without quotes).

 
Sample Input
4 11
8.02
7.43
4.57
5.39
0 0
 
Sample Output
2.00
 
 
 
 
 
题的大意是:有n根电线,要分成m段,问能分成m段的最大的长度是多少?、
 
用二分法求!
 
和杭电1969一样的题,不多说了。详细信息可以去看我的hdu1969
 
 #include<stdio.h>
#include<iostream>
#include<algorithm>
#include<math.h>
using namespace std;
double L[];
int a,b,i;
bool F(double x)
{
int sum=;
for(i=;i<a;i++)
sum +=(int)(L[i]/x);
return sum >= b;
}
void ww()
{
double l=,r=,mid;
while(r-l>1e-)
{
mid=(r+l)/;
if(F(mid))
l=mid;
else
r=mid;
}
r=(int)(r*)/100.0;
printf("%.2f\n",r);
}
int main()
{
scanf("%d%d",&a,&b);
for(i=;i<a;i++)
scanf("%lf",&L[i]);
ww(); return ;
}
 
 

Cable master--hdu1551(二分法)的更多相关文章

  1. POJ 1064 Cable master (二分法+精度控制)

    Cable master Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 65358   Accepted: 13453 De ...

  2. hdu 1551 Cable master (二分法)

    Cable master Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Tota ...

  3. Cable master 求电缆的最大长度(二分法)

    Description Inhabitants of the Wonderland have decided to hold a regional programming contest. The J ...

  4. HDU1551&&HDU1064 Cable master 2017-05-11 17:50 38人阅读 评论(0) 收藏

    Cable master                                                                            Time Limit: ...

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

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

  6. poj1064 Cable master(二分)

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

  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 ...

  10. POJ 1064 Cable master

    Cable master Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 37865   Accepted: 8051 Des ...

随机推荐

  1. [Head First Python]4. pickle.dump pickle.load

    sketch.py #--*-- coding:utf-8 --*-- import pickle import nester man = [] other = [] try: data = open ...

  2. 如何调用EcStore中的API接口

    EcStore系统已内置了丰富的API接口供外部系统调用(接口列表见文章最下面),外部系统具体如何调用这些API呢? 例如有一个PHP的论坛需要调用ecstore系统内一个商品的详情,则可以使用b2c ...

  3. DLL技术应用03 - 零基础入门学习Delphi46

    DLL技术应用03 让编程改变世界 Change the world by program DLL的加载和调用 [caption id="attachment_2685" alig ...

  4. Azure上A/D系列虚拟机到DS系列迁移(2)

    11. 该脚本会检测环境,停止虚拟机,拷贝VHD文件,创建磁盘等等,知道出现如下类似画面,他会暂停等待用户操作: 后面这几个步骤非常重要,关系到你后续的创建是否成功: 12. 进入D:\migvm目录 ...

  5. OSA-MAC: A MAC Protocol for Opportunistic Spectrum Access in Cognitive Radio Networks

    This full text paper was peer reviewed at the direction of IEEE Communications Society subject matte ...

  6. List 随机排序

    List<T> l = new List<T>(); l = l.Select(a => new { a, newID = Guid.NewGuid() }).Order ...

  7. SQL Server 2008空间数据应用系列五:数据表中使用空间数据类型

    原文:SQL Server 2008空间数据应用系列五:数据表中使用空间数据类型 友情提示,您阅读本篇博文的先决条件如下: 1.本文示例基于Microsoft SQL Server 2008 R2调测 ...

  8. Android的debug.keystore拒绝访问导致的生成异常及解决方案

    构建Android应用程序的时候输出异常:[apkbuilder] keytool 错误: java.io.FileNotFoundException: C:\Users\my\.android\de ...

  9. WordPress SEO ☞ WordPress网站终极优化指南

    原文地址:http://www.eastdesign.net/wordpress-seo/ 最新消息,东方设计学院 WordPress SEO 系列视频教程正在持续更新中,目前为了不至于让视频传播过于 ...

  10. 有序线性搜索(Sorted/Ordered Linear Search)

    如果数组元素已经排过序(升序),那我们搜索某个元素就不必遍历整个数组了.在下面给出的算法代码中,到任何一点,假设当前的arr[i]值大于搜索的值data,就可以停止搜索了. #include<s ...