POJ 1064 Cable Master

Source: Internet
Author: User

F-Cable MasterTime limit:MS Memory Limit:10000KB 64bit IO Format:%i64d &%i64u SubmitStatusPracticePOJ 1064

Description

Inhabitants of the Wonderland has decided to hold a regional programming contest. The judging committee has volunteered and have promised to organize the most honest contest ever. It is decided to connect computers for the contestants using a ' star ' topology-i.e. Connect them all to a single centra L Hub. To organize a truly honest contest, the Head of the judging committee have decreed to place all contestants evenly around T He hub on the equal distance from it.
To buy network cables, the judging committee have contacted a local network solutions provider with a request to sell for T Hem a specified number of cables with equal lengths. The judging committee wants the cables to being as long as possible to sit contestants as far from each other as possible.
The Cable Master of the company is assigned to the task. He knows the length of each cable in the "stock up" Centimeter,and he can cut them with a centimeter precision being to LD the length of the pieces he must cut. However, this time, the length was not known and the Cable Master is completely puzzled.
The Cable Master, by writing a program that would determine the maximal possible length of a Cable piece th At can is cut from the cables in the stock, to get the specified number of pieces.

Input

The first line of the input file contains the 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 the requested pieces. The first line was followed by N lines with a number per line, which specify the length of each cable in the the stock in Mete Rs. All cables is at least 1 meter and at the most of the kilometers in length. All lengths in the input file is written with a centimeter precision, with exactly, and digits after a decimal point.

Output

Write to the output file, the maximal length (in meters) of the pieces, Cable Master may cut from the cables in the STO CK to get the requested number of pieces. The number must is written with a centimeter precision, with exactly, and digits after a decimal point.
If It isn't possible to cut the requested number of pieces each one being at least one centimeter long and then the output F Ile must contain the single number "0.00" (without quotes).

Sample Input

4 118.027.434.575.39

Sample Output

2.00


 #include <iostream> #include <stdio.h> #include <string> #include <    Cstring> #include <algorithm>using namespace std;double a[100009];int Fun (double x,int n) {int num=0;    for (int i=0;i<n;i++) {num+=int (a[i]/x); } return num;}    int main () {int n,k;    Double Mx,mid,sum,ans;        while (cin>>n>>k) {sum=0;            for (int i=0;i<n;i++) {scanf ("%lf", &a[i]);            if (Mx<a[i]) mx=a[i];        Sum+=a[i];            } if (sum*100<k)//up to sum/0.01 root length 0.01 m rope {cout<< "0.00" <<endl;        Continue        } int le=0,ri=mx*100,ss;//accuracy problem really pits the dead.            while (Ri>=le) {ss= (Le+ri)/2;            mid=ss/100.0;            if (Fun (mid,n) >=k) le=ss+1;        else ri=ss-1;        } ans=ri/100.0;    printf ("%.2lf\n", ans); } return 0;} 


POJ 1064 Cable Master

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.