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. Javascript 浏览器检测

    推荐 Browser Detecter, 很好用,自己也很容易扩展. 原文链接:http://www.quirksmode.org/js/detect.html <script type=&qu ...

  2. Windows10系统一键结束所有运行程序

    当电脑及其卡顿的时候,想打开任务管理器关掉所有运行的程序的时候,也会变得及其困难.因此之前你如果有犀利的小程序设置,这都不会是问题. 1)空白处右键-新建-快捷方式 2)将下列代码复制到下列框中(注意 ...

  3. Path-O-LOGIC Keynote

    [Path-O-LOGIC Keynote] 1. OnSpawned()OnSpawned(SpawnPool pool) 2. OnDespawned()OnDespawned(SpawnPool ...

  4. 西南交通大学结构服役安全及力学基础创新团队在Wiley出版英文专著(转载)

    近日,西南交通大学力学与工程学院康国政教授与阚前华副教授受邀由John Wiley & Sons Ltd公司出版了英文专著 “Cyclic plasticity of Engineering  ...

  5. 4. Median of Two Sorted Arrays(Array; Divide-and-Conquer)

    There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two ...

  6. Dungeon Game (GRAPH - DP)

    QUESTION The demons had captured the princess (P) and imprisoned her in the bottom-right corner of a ...

  7. ES5之defineProperty

    一 概述 Object.defineProperty() 方法会直接在一个对象上定义一个新属性,或者修改一个对象的现有属性, 并返回这个对象. 对象里目前存在的属性描述符有两种主要形式:数据描述符和存 ...

  8. 14-n皇后

    /*题目内容: 国际象棋中的皇后可以沿着水平线,垂直线,或者斜线前进,吃掉遇到的所有棋子,如果棋盘上有八个皇后,则这八个皇后如何相安无事的放置在棋盘上,1970年与1971年, E.W.Dijkstr ...

  9. js-移动端android浏览器中input框被软键盘遮住的问题解决方案

    我遇到的问题:在一个页面里有一个弹出层之前我给我的最外层加了固定定位 用了下面的方法也不好使:没有办法我将之改为绝对定位层级变高在加上一个顶部标签通过js计算顶部高度来实现满屏遮挡: <sect ...

  10. sdk接入

    文档 http://blog.csdn.net/chenjie19891104/article/details/42217281 视频: https://chuanke.baidu.com/v2869 ...