Cable master

                                                                           Time Limit: 2000/1000 MS (Java/Others)    Memory Limit:
65536/32768 K (Java/Others)

                                                                                                      Total Submission(s): 4673    Accepted Submission(s): 1769

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
 
Source
 
Recommend
LL

—————————————————————————————————
题目的意思是给出n根绳子, 问分成m段最长可以达到多长,分解时最大到1cm
思路:先整体扩大100倍化成整数,二分+验证求解
#include <iostream>
#include<queue>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<set>
#include<cstring>
using namespace std;
#define LL long long int n,k;
double a[100005];
int b[100005];
bool ok(int x)
{
int ans=0;
for(int i=0; i<n; i++)
{
ans+=b[i]/x;
}
if(ans>=k)
return 1;
else
return 0;
} int main()
{
while(~scanf("%d%d",&n,&k))
{
for(int i=0; i<n; i++)
{
scanf("%lf",&a[i]);
b[i]=a[i]*100;
}
int l=1,r=10000000;
int ans;
while(l<=r)
{
int mid=(l+r)/2;
if(ok(mid))
{
l=mid+1;
ans=mid;
}
else
{
r=mid-1;
}
}
double an=ans*1.0/100;
printf("%.2f\n",an);
}
return 0;
}



HDU1551&&HDU1064 Cable master 2017-05-11 17:50 38人阅读 评论(0) 收藏的更多相关文章

  1. POJ2456 Aggressive cows 2017-05-11 17:54 38人阅读 评论(0) 收藏

    Aggressive cows Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 13993   Accepted: 6775 ...

  2. Java中的日期操作 分类: B1_JAVA 2015-02-16 17:55 6014人阅读 评论(0) 收藏

    在日志中常用的记录当前时间及程序运行时长的方法: public void inject(Path urlDir) throws Exception { SimpleDateFormat sdf = n ...

  3. Cubieboard 开箱和入门 | Name5566 分类: cubieboard 2014-11-08 17:27 251人阅读 评论(0) 收藏

    Cubieboard 开箱和入门 2014 年 01 月 29 日 by name5566 Categories: Computer Science, Cubieboard Hello Cubiebo ...

  4. APP被苹果APPStore拒绝的各种原因 分类: ios相关 app相关 2015-06-25 17:27 200人阅读 评论(0) 收藏

    APP被苹果APPStore拒绝的各种原因 1.程序有重大bug,程序不能启动,或者中途退出. 2.绕过苹果的付费渠道,我们之前游戏里的用兑换码兑换金币. 3.游戏里有实物奖励的话,一定要说清楚,奖励 ...

  5. POJ3258 River Hopscotch 2017-05-11 17:58 36人阅读 评论(0) 收藏

    River Hopscotch Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 13598   Accepted: 5791 ...

  6. 多校4-Walk Out 分类: 比赛 2015-08-02 17:15 21人阅读 评论(0) 收藏

    Walk Out Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Total Subm ...

  7. MessageFlood 分类: 串 2015-06-18 17:00 10人阅读 评论(0) 收藏

    MessageFlood TimeLimit: 1500ms Memory limit: 65536K 有疑问?点这里^_^ 题目描述 Well,how do you feel about mobil ...

  8. Hdu 1429 胜利大逃亡(续) 分类: Brush Mode 2014-08-07 17:01 92人阅读 评论(0) 收藏

    胜利大逃亡(续) Time Limit : 4000/2000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other) Total Subm ...

  9. strace使用详解(转) 分类: shell ubuntu 2014-11-27 17:48 134人阅读 评论(0) 收藏

    (一) strace 命令    用途:打印 STREAMS 跟踪消息. 语法:strace [ mid sid level ] ... 描述:没有参数的 strace 命令将所有的驱动程序和模块中的 ...

随机推荐

  1. Oracle免客户端InstantClient安装使用

    正常情况下,用PL/SQL等软件连接Oracle,需要安装Oracle客户端软件,一般安装oracle客户端差不多需要2G左右的硬盘空间,但如果我们仅仅是连接数据库进行查询和执行一些相应的语句而不进行 ...

  2. Spring,Hibernate 集成解决多hbm.xml文件繁多的方案

    开发一个大一点的项目有很多的hbm.xml文件,有时候上百个也不稀奇,如果用 <property name="mappingLocations"> <list&g ...

  3. 常用类一一字符串相关类一一String类 字符串的使用

    Java字符串就是Unicode字符序列,例如“Java”就是4个Unicode字符J,a,v,a组成的. Java没有内置的字符串类型,而是在标准Java类库中提供了一个预定义的类String,每个 ...

  4. 在windows 2008 R2中SQl Server 2008中代理启动失败的一个原因总结

    启动SQL代理的时候报错如下: 关调用实时(JIT)调试而不是此对话框的详细信息,请参见此消息的结尾. ************** 异常文本 **************System.NullRef ...

  5. Centos7 vnc

    这是一个关于怎样在你的 CentOS 7 上安装配置 VNC 服务的教程.当然这个教程也适合 RHEL 7 .在这个教程里,我们将学习什么是 VNC 以及怎样在 CentOS 7 上安装配置 VNC ...

  6. Ubuntu 安装 Zabbix 3.2详细步骤

    创建 zabbix 用户 因为zabbix 程序的守护进程需要非特权用户,所以需要创建一个 zabbix 用户,即使从 root 用户启动 zabbix 程序,也会自动切换到 zabbix 用户,所以 ...

  7. CentOS7使用yum详细搭建zabbix3.2过程

    本文引用于:http://blog.csdn.net/s3275492383/article/details/62417210 一.准备搭建环境: 1.系统:CentOS7 2.默认有使用linux服 ...

  8. Loadrunner进行参数化

    Loadrunner进行参数化 Loadrunner中进行参数化,这里有三种方法. 对需要多次使用的变量进行参数化,比如登录信息的用户名和密码,首先需要选中需要参数化的值,然后右键选择Replace ...

  9. pre换行段落间距

    <!DOCTYPE html><html><head lang="en"><meta charset="UTF-8"& ...

  10. 通过阿里OSS文件服务返回的URL获取文件流下载

    我们都知道将文件上传到阿里的OSS文件服务上后,可以通过generatePresignedUrl(bucketName, key, expiration)方法获取该文件的防问路径,但是当我们知道该文件 ...