标签:window printf div click gray namespace lap code sed
2146 分割绳子http://www.51nod.com/Challenge/Problem.html#problemId=2146
#include <bits/stdc++.h> using namespace std; double a[1005]; int n,k; int check(double x){ int num = 0; for(int i = 0; i < n; i++) num += (int)(a[i] / x); return num >= k; } int main(){ //freopen("in","r",stdin); cin >> n >> k; double l = 0,r = 0; for(int i = 0; i < n; i++){ cin >> a[i]; r += a[i]; } for(int i = 0; i < 100; i++){ double mid = (l + r) / 2; if(check(mid)) l= mid; else r = mid; } printf("%.2lf",r); return 0; }
标签:window printf div click gray namespace lap code sed
原文地址:https://www.cnblogs.com/xcfxcf/p/12395309.html