标签:
Time Limit: 1000MS | Memory Limit: 10000K | |
Total Submissions: 37865 | Accepted: 8051 |
Description
Input
Output
Sample Input
4 11 8.02 7.43 4.57 5.39
Sample Output
2.00
Source
#include <cstdio> #include <cmath> double a[10005]; int n, k; bool ok(double x) { int num = 0; for(int i = 0; i < n; ++i){ num += (int)(a[i]/x); } return num >= k; } int main() { scanf("%d%d", &n, &k); for(int i = 0; i < n; ++i) scanf("%lf", &a[i]); double l = 0, r = 1e5+5; for(int i = 1; i < 100; ++i){ double mid = (l+r)/2; if(ok(mid)) l = mid; else r = mid; } printf("%.2f\n", floor(l*100)/100); return 0; }
标签:
原文地址:http://www.cnblogs.com/inmoonlight/p/5746981.html