【题目描述】
【思路】
实数二分法
import java.util.Scanner;
public class Main{
static int N = 100010;
static int a[] = new int[N];
static double n,m;
public static boolean check(double mid){
//绳子被切割成mid长度的段数
int cnt = 0;
for(int i = 0; i < n; i++ )
cnt += a[i]/mid;
return cnt >= m;
}
public static void main(String args[]){
Scanner reader = new Scanner(System.in);
n = reader.nextInt();
m = reader.nextInt();
for(int i = 0; i < n; i++) a[i] = reader.nextInt();
double l = 0;
double r = 1.0E9;
while(r-l > 1.0E-4){
double mid = (l+r)/2;
if(check(mid)) l = mid;
else r = mid;
}
System.out.printf("%.2f",r);
}
}