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. C# ConcurrentDictionary实现

    ConcurrentDictionary的源码看了很多遍,今天抽点时间整理一下,它的实现比Dictionary要复杂很多,至于线程安全我觉得比较简单,用的是lock的思想.首先我们来看看它的源码. p ...

  2. iOS开发-适配器和外观模式

    适配器模式,属于结构型模式,其主要作用是将一个类的接口转换成客户希望的另外一个接口.适配器模式使得原本由于接口不兼容而不能一起工作的那些类可以一起工作.适配器模式有对象适配器和类适配器两种,类适配器模 ...

  3. Word批量删除所有书签

    Word中的书签功能可快速.准确定位文档中特定的位置,经常用于模板定制.文档产出等. 可一直以来,书签功能存在一个不便的操作,即无法批量删除,只能单个删除,操作极不友好. 解决方案 我用代码暂时还改变 ...

  4. What's the difference between ConcurrentHashMap and Collections.synchronizedMap(Map)?

    来自:http://stackoverflow.com/questions/510632/whats-the-difference-between-concurrenthashmap-and-coll ...

  5. C# System.Collections.Stack

    using System; using System.Collections; public class SamplesStack { public static void Main() { // C ...

  6. Spring MVC实现上传文件报错解决方案

    报错代码: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.sp ...

  7. plsql 操纵表数据的2种方式

      1.情景展示 在plsql中,对表的操作(增.删.改.查),其实有2种方式,只是很多人都只会第一种方式罢了. 2.方式介绍 第1种方式:直接将值与sql写到一起 直接按F8运行即可. 第2种方式: ...

  8. 关于input时间框设置了弹出选择就不能手动输入的控制

    <input class="Wdate" onclick="WdatePicker({minDate:'#F{$dp.$D(\'startDate\');}',ma ...

  9. Java list对象列表排序 实例

    package com.test; public class Bean { private String name; private int priority; public String getNa ...

  10. 一个vue请求接口渲染页面的例子

    new Vue({ el:'#bodylist', data: { list: [ { "type_id": "1", "type_name" ...