Hangzhou Electric 1551--cable Master (two minutes)

Source: Internet
Author: User

Cable Master

Time limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)
Total submission (s): 2606 Accepted Submission (s): 970


Problem descriptioninhabitants 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 to a centimeter, and he can cut them with a centimeter precision being t Old 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.

Inputthe input consists of several testcases. The first line of each testcase contains-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 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 centimeter and at the most of the kilometers in length. All lengths in the input is written with a centimeter precision, with exactly, and digits after a decimal point.

The input is ended by line containing 0 ' s.

Outputfor each testcase write to the output the maximal length (in meters) of the pieces, Cable Master may cut from th e cables in the stock 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 m UST contain the single number "0.00" (without quotes).

Sample Input4 11 8.02 7.43 4.57 5.39 0 0

Sample Output2.00

source2001-2002 ACM Northeastern European Regional Programming Contest

Recommendll |     We have carefully selected several similar problems for you:2333 2298 1399 2446 1969 test Instructions: N-segment line cut into K-segment (equal length), for maximum length, two-point search for maximal length; Precision this kind of thing is not good, confused on a,
1#include <stdio.h>2 using namespacestd;3 Doublenum[10010];intI, n, K;4 intFDoublex)5 {6     intTotal =0;7      for(i=0; i<n; i++)8Total + = (int) (num[i]/x);9     returntotal>=K;Ten } One intMain () A { - //int n, K; -      while(~SCANF ("%d%d", &n, &k)) the     { -         if(n==0&& k==0) -              Break; -         Doublemax =-1; +          for(i=0; i<n; i++) -         {  +scanf"%LF", &num[i]); A             if(Num[i] >max) atMax =Num[i]; -         } -         Doubleleft =0.01, right = max, Mid;//Left = 0;→→wa! -          while(Right-left > 1e-4) -         { -Mid = (right + left)/2; in             if(f (mid)) left =mid; -             Elseright =mid; to         } +Mid= (Double)(int) (mid* -)/ -;//WA. -printf"%.2f\n", mid); the     } *}

Hangzhou Electric 1551--cable Master (two minutes)

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.