Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
用右端点r就ac#include <iostream> using namespace std; const int N = 10010; double lines[N]; int n,k; bool check(double mid){ int cnt = 0; for (int i = 0;i < n;i++) cnt += (int)(lines[i]/mid); return cnt >= k; } int main(){ cin >> n >> k; for (int i = 0; i < n; i++ ) { cin >> lines[i]; } double l = 0,r = 1e5,mid,eps = 1e-8; while (l + eps < r){ mid = (l + r)/2; if (check(mid)) l = mid; else r = mid; } printf("%.2lf\n",(int)(r*100)/100.0); return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator