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. 趣味编程:CPS风格代码(C++11, C++14版)

    CPS风格代码(C++11版) #include <iostream> using namespace std; int add(int x, int y){return x + y;} ...

  2. 使用robotium对android应用进行自动化测试

    所需要的环境: 1.eclipse 2.android development tools(ADT) 3.software develoment kit(SDK) 4.JDK 5.robotium 1 ...

  3. Scripting API Samples

      Scripting API Samples Tomáš Matoušek edited this page on Jan 31 · 32 revisions Home API Changes Bu ...

  4. java jpa 报错

    表的字段名不能是数据库的关键字 INSERT INTO `todo`.`todo_item` (description, completed) VALUES ('test 111', false); ...

  5. Null Hypothesis and Alternate Hypothesis

    1.Null Hypothesis Overview 零假设,H0是普遍接受的事实;这与备择假设(alternate hypothesis)正好相反.研究人员努力否定.驳斥零假设.研究人员提出了另一种 ...

  6. Excel日期处理

    short format = cell.getCellStyle().getDataFormat(); //其值为22 输入值类型为2018/6/28 17:25:48 if (format!=22) ...

  7. Linux Shell 文本处理工具集锦(转载)

    内容目录: find 文件查找 grep 文本搜索 xargs 命令行参数转换 sort 排序 uniq 消除重复行 用tr进行转换 cut 按列切分文本 paste 按列拼接文本 wc 统计行和字符 ...

  8. rapidjson使用

    Value构造 Value对象最好先声明后初始化,如果声明直接初始化可能出错. rapidjson::Value a; a = val[i]; Value传参 Value传参,最好显式使用右值,如st ...

  9. Python中类的定义与使用

    目标: 1.类的定义 2.父类,子类定义,以及子类调用父类 3.类的组合使用 4.内置功能 1.类的定义 代码如下: #!/usr/bin/env python #coding:utf8 class ...

  10. VS 窗体大小

    锁定窗体大小,就是鼠标停在窗口边框的时候,不能拖动来改变它的大小…… 有两种方法: 1.可以把Form的属性 FormborderStyle 后面选择 FixedDialog 2.或者把Form窗体的 ...