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 |
化成int后二分,贴份代码#include <iostream> using namespace std; int L[10005]; int main() { int N, K, num, lb = 0, rb = 1, mid; double c; cin >> N >> K; for (int i = 0; i < N; i++) { cin >> c; L[i] = (int)(c * 10000 + 0.1); if (L[i] > rb) { rb = L[i]; } } while (rb - lb > 1) { mid = (lb + rb) >> 1; num = 0; for (int i = 0; (i < N) && (num < K); i++) { num += (L[i] / mid); } if (num >= K) { lb = mid; } else { rb = mid; } } lb = (lb + 5) / 100; cout << lb / 100 << '.' << (lb % 100) / 10 << lb % 10 << '\n'; return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator