基础二分:华华拆木棍
import java.io.*; import java.util.*; public class Main { static long a[]; static int k,n; public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); n = sc.nextInt(); k = sc.nextInt(); a = new long[n]; for(int i = 0;i < n;i++){ a[i] = sc.nextLong(); } long l = 0; long r = 1000000009,mid; while(l < r - 1) { mid = (l + r) / 2; if(check(mid)){ l = mid; }else { r = mid - 1; } } if(check(l + 1)){ l++; } System.out.println(l); } public static boolean check(long x){ int sum = 0; for(int i = 0;i < n;i++){ sum+=(a[i] / x); } return sum >= k?true:false; } }