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. css布局学习笔记之max-width

    设置块级元素的 width 可以阻止它从左到右撑满容器.然后你就可以设置左右外边距为 auto 来使其水平居中.元素会占据你所指定的宽度,然后剩余的宽度会一分为二成为左右外边距. div{ width ...

  2. 火星A+B..(不贴代码了)

    还是A+B Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submi ...

  3. Java 学习 第一篇

    1:Java文档注释:使用javadoc工具可以提取程序中文档注释来生成API文档:javadoc命令的基本用法:javadoc 选项 java源文件/包javadoc -d {} -windowti ...

  4. 【温故而知新-万花筒】C# 异步编程 逆变 协变 委托 事件 事件参数 迭代 线程、多线程、线程池、后台线程

    额基本脱离了2.0 3.5的时代了.在.net 4.0+ 时代.一切都是辣么简单! 参考文档: http://www.cnblogs.com/linzheng/archive/2012/04/11/2 ...

  5. tr 替换删除字符

    1.关于tr    通过使用 tr,您可以非常容易地实现 sed 的许多最基本功能.您可以将 tr 看作为 sed 的(极其)简化的变体:它可以用一个字符来替换另一个字符,或者可以完全除去一些字符.您 ...

  6. Multiple outputs from T4 made easy – revisited » DamienG

    Multiple outputs from T4 made easy – revisited » DamienG Multiple outputs from T4 made easy – revisi ...

  7. express设置ejs并将后缀改为html

    http://www.cnblogs.com/-nothing-/p/4943354.html http://blog.csdn.net/macyang/article/details/8841966 ...

  8. EasyUI DataGrid编辑单元格时使用combogrid

    仅提供一段columns配置代码供参考: conditions对象是一个已赋值的数组对象集合.下拉框数据可直接使用conditions数据,也可以通过url获取. columns : [[ { fie ...

  9. 字符串和数字的全排列问题、前i位被i整除问题

    // 全排列问题.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" #include <iostream> using names ...

  10. RehHat enterprise 5.4 安装git

    今天想来研究一下git,就自己安装一个试试,没想到遇到各种问题.经过各种百度和google,终于都解决了,现在来总结一下: 1.安装完redhat 5.4,安装gcc编译器的问题:这个gcc编译器需要 ...