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 first line of the input file contains two integer numb ers 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 meter and at most 100 kilometers in length. All lengths in the input file are written with a centimeter precision, with exactly two digits after a decimal point.

Output

Write to the output file 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 file must contain the single number "0.00" (without quotes).

Sample Input

4 11

8.02

7.43

4.57

5.39

Sample Output

2.00

二分我肯定是个傻子要注意给的单位是木..;

#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include <iomanip>
#include<cmath>
#include<string.h>
#include<algorithm>
#define sf scanf
#define pf printf
#define pb push_back
#define mm(x,b) memset((x),(b),sizeof(x))
#include<vector>
#include<map>
#define for(i,a,b) for(int i=a;i<b;i++)
typedef long long ll;
typedef long double ld;
const ll mod=1e9+7;
using namespace std;
const double pi=acos(-1.0);
double b[10005];int n,m,a[10005];
bool judge(int mid)
{
int sum=0;
for(i,0,n)
{
sum+=a[i]/mid;
}
return sum>=m;
}
int main()
{
int sum=0;
int Max=0;
cin>>n>>m;
for(i,0,n)
{
cin>>b[i];
a[i]=b[i]*100;
sum+=a[i]/100;
Max=max(Max,a[i]);
}
/* if(sum<m)
{
cout<<"0.00";
return 0;
}*/
int left=0,right=Max+1,mid;
while(right-left>1)
{
mid=(left+right)/2;
if(judge(mid))
left=mid;
else
right=mid;
}
if(judge(right))pf("%.2f",(double)right/100.00);
else
pf("%.2f",(double)left/100.00);
return 0;
}

A - Cable master的更多相关文章

  1. POJ 1064 Cable master (二分)

    题目链接: 传送门 Cable master Time Limit: 1000MS     Memory Limit: 65536K 题目描述 有N条绳子,它们长度分别为Li.如果从它们中切割出K条长 ...

  2. [ACM] poj 1064 Cable master (二分查找)

    Cable master Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 21071   Accepted: 4542 Des ...

  3. Cable master(二分题 注意精度)

    Cable master Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 26596   Accepted: 5673 Des ...

  4. POJ 1064 Cable master

    Cable master Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 37865   Accepted: 8051 Des ...

  5. Cable master

    Description Inhabitants of the Wonderland have decided to hold a regional programming contest. The J ...

  6. (poj)1064 Cable master 二分+精度

    题目链接:http://poj.org/problem?id=1064 Description Inhabitants of the Wonderland have decided to hold a ...

  7. poj 1064 Cable master【浮点型二分查找】

    Cable master Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 29554   Accepted: 6247 Des ...

  8. POJ 1064 Cable master(二分查找+精度)(神坑题)

    POJ 1064 Cable master 一开始把 int C(double x) 里面写成了  int C(int x) ,莫名奇妙竟然过了样例,交了以后直接就wa. 后来发现又把二分查找的判断条 ...

  9. Cable master(好题,二分)

    Cable master Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Tota ...

  10. [ACM] poj 1064 Cable master (二进制搜索)

    Cable master Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 21071   Accepted: 4542 Des ...

随机推荐

  1. yum离线安装rpm包

    CentOS利用yum下载好rpm包,并离线安装   1.联网安装好rpm包,并将下载好的包备好 #yum install --downloadonly --downloaddir=/home/sam ...

  2. gcc下inline的一个问题

    今天发现一个问题,与inline有关,也与编译时候是不是优化有关. 大概问题可以用下面的代码来描述: 先写一个libtest1,代码如下 libtest1.h #ifndef LIBTEST_H #d ...

  3. MySQL MySql连接数与线程池

    连接数 1.  查看允许的最大并发连接数 SHOW VARIABLES LIKE 'max_connections'; 2.  修改最大连接数 方法1:临时生效 SET GLOBAL max_conn ...

  4. redhat7.0配置网卡

    1.切换到网卡配置目录: cd /etc/sysconfig/network-scripts 2.编辑网卡信息 如 vim ifcfg-enpos3 TYPE=Ethernet #设备类型 BOOTP ...

  5. MVC 打印解决方案--SNF快速开发平台3.1

    SNF-MVC打印报表方案: 报表模块创建的过程如下: 利用Stimulsoft Reports客户端报表工具新增一个报表文件 *.mrt 当然你也可以拿好用的*.mrt模版文件进行复制出来一个,我常 ...

  6. Android Error:Execution failed for task ':app:compileDebugJavaWithJavac' 解决方案

    今天使用 Android Studio 构建项目的时候出现了这个错误 compileDebugJavaWithJavac 通过搜索发现造成该问题的原因有很多需要结合具体的项目进行排查 通过 Andro ...

  7. Android studio ButterKnife插件

    1.功能:给所有的有id的控件添加注解 2.github地址 https://github.com/avast/android-butterknife-zelezny 3.插件下载地址 http:// ...

  8. IIS发布的网站常见的问题汇总

    1.安装.NET4.0时缺少WIC导致不能装上.NET4.0,下载安装后即可,下载地址如下,根据系统版本选择对应软件 32位版:https://www.microsoft.com/zh-cn/down ...

  9. vue中全选和取消

    1.效果预览 2.index.html <!DOCTYPE html> <html lang="en"> <head> <meta cha ...

  10. python 的正则表达式

    在python中,对正则表达式的支持是通过re模块来支持的.使用re的步骤是先把表达式字符串编译成pattern实例,然后在使用pattern去匹配文本获取结果. 其实也有另外一种方式,就是直接使用r ...