Openjudge NOI test Bank ch0111/t1776 Wood Processing

Source: Internet
Author: User

Total time limit:
1000ms
Memory Limit:
65536kB
Describe
Wood Factory There are some logs, now want to cut these wood into some of the same length of small pieces of wood, need to get the number of small pieces is given. Of course, the longer we want to get the smaller segment the better, your task is to calculate the maximum length of the small piece of wood that can be obtained.

The unit of wood length is centimeters. The length of the log is a positive integer, and the length of the small piece of wood we require to be cut is also required to be a positive integer.
Input

The first line is two positive integers n and K(1≤ n ≤ 10000, 1≤ K ≤10000),n is the number of logs,K is the number of small segments that need to be obtained.
The next N rows, each line has a positive integer between 1 and 10000, representing the length of a log.
 

Output
The maximum length of the small segment that the output can be cut. If the 1 cm length of the small segment can not be cut out, output "0".
Sample input
3 7232124456
Sample output
114
Source
NOIP 2004

This question and ch0111/04 is the same practice, here is detailed introduction.

Ps put N, k input comment out can get 1 points!

1#include <stdio.h>2 intlen[10010]={0};3 intMain ()4 {5     inti;6     intmax=-1;7     intN,k,ans,mid;8     intr,l;9scanf"%d%d",&n,&k);Ten      for(i=0; i<n;i++) One     { Ascanf"%d",&len[i]); -         if(Len[i]>max) max=Len[i]; -     } theL=0; -r=max+1; -      while(L +1&LT;R)//two points to find the right length -     { +ans=0; -Mid= (L+R)/2; +          for(i=0; i<n;i++) Aans+=len[i]/mid; at         if(ans>=k) l=mid; // pay attention to the condition control here.   -         ElseR=mid; -     } -printf"%d", L); -     return 0; -}

Openjudge NOI test Bank ch0111/t1776 Wood Processing

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.