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 white-space

    以下是对上面几个属性的测试效果如下: 具体代码如下: <!DOCTYPE html> <html lang="en"> <head> <m ...

  2. CSS浏览器兼容问题集-第一部分

    CSS对浏览器的兼 容性有时让人很头疼,或许当你了解当中的技巧跟原理,就会觉得也不是难事,从网上收集了IE7,6与Fireofx的兼容性处理方法并整理了一下.对于 web2.0的过度,请尽量用xhtm ...

  3. HDU 1172 猜数字(DFS)

    猜数字 Time Limit:10000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status ...

  4. mysql的client和sever之间通信password的传输方式

    本文想要说明的是,当我们用mysql -uroot -p1234567 -h127.0.0.1 -P3306 去连接mysql server时密码是通过什么样的形式传过去的呢? 首先密码这种东西明文传 ...

  5. IOS开发之动态获取模型的属性值

    #import "model.h" #import <objc/runtime.h> @implementation model +(instancetype)mode ...

  6. debian gnome 3插件

    1.gnome 配置-安装插件 http://maxubuntu.blogspot.com/2012/09/debian-gnome3.html hunagqf|hunaqf2|hunaqf3 2.快 ...

  7. python list列表 方法总结

    深入链表(most on lists) The list data type has some more methods. Here are all of the methods of list ob ...

  8. IOS深入学习(4)之Coordinate System

    1 前言 在IOS中相信大家会经常跟一些bounds,frame之类的打交道,这不免会涉及坐标系统,今天我们就来介绍一下Coordinate System(坐标系). 2 详述 坐标系统是定位,大小, ...

  9. jsp定时方法

    jsp定时方法 $(function(){ totaladd(); //定时时触发的函数 setInterval(totaladd,);//设置定时1000=1秒 }); function total ...

  10. iOS 7 改变Status Bar 颜色

    Set the UIViewControllerBasedStatusBarAppearance to NO in the Info.plist. In ViewDidLoad method or a ...